-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.tech/enginesIssue for tech Engines.Issue for tech Engines.topic: JsonScalar type `Json`Scalar type `Json`topic: relationJoins
Description
Bug description
We have a field called "layout" that is a JSON stored inside a template schema, we have noticed that our templates were crashing because out of order, after analysing what happened we have seen that in the database was in the correct order but after calling:
const collectionWithTemplates = await prisma.collection.findMany({ include: { template: true }})The template object which contains a layout field that is a @db.JSON was not ordered/preserved the order correctly.
How to reproduce
Simply create an schema with a relation with json field, and fetch this field through a relation
Expected behavior
It should keep the order
Prisma information
Prisma schema
generator client {
provider = "prisma-client-js"
output = "../../../packages/prisma-client/client"
previewFeatures = ["fullTextSearch", "tracing", "relationJoins", "nativeDistinct"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Collection {
id String @id @default(uuid()) @db.Uuid
templateId String @db.Uuid
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
}
model Template {
id String @id @default(uuid()) @db.Uuid
layout Json @db.Json
collections Collection[]
}Code to check
const template = await prisma.collection.findFirst({
include: {
template: true,
},
});Environment & setup
- OS: Ubuntu/Mac
- Database: PostgreSQL
- Node.js version: Node 18
Prisma Version
5.7.1
imwexpex and xentobias
Metadata
Metadata
Assignees
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.tech/enginesIssue for tech Engines.Issue for tech Engines.topic: JsonScalar type `Json`Scalar type `Json`topic: relationJoins