Closed piscopancer closed 1 week ago
Must be the duplicate of/similar to #1518.
Hi @piscopancer , do you mind sharing the definition of the Course
model in ZModel? I'd like to understand how it uses the polymorphic models.
@ymc9 sure
model Course {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
title String
description String?
tutorId Int
tutor User @relation("created-courses", fields: [tutorId], references: [id], onDelete: Cascade)
groups Group[]
works Work[] @relation("courses-works")
students User[] @relation("participated-courses")
addedToNotifications AddedToCourseNotification[]
worksStates WorkState[]
attempts Attempt[]
}
Hi @piscopancer , it should have been fixed in the v2.2.4 release. Could you upgrade and give it a try?
@ymc9 incredible! the command from above works now, thank you for maintaining this project winks
Bug
This operation fails (prisma throws an error)...
... because generated prisma schema wrongly replicates
id
from the table it extends from. See the model for my MTI relationsschema.zmodel
now take a look at the generated
prisma.schema
prisma.schema
As you can clearly see,
id
columns ofAddedToGroupNotification
andAddedToCourseNotification
do not have parent's properties/functions, namely@default(autoincrement())
. Because of this, the operation from the first code block fails even though typescript, generated by zenstack allows omittingid
which is obviously an unexpected behavior and mismatch:id
does not have@default(autoincrement())
which means it is expected to be provided directly by me from the code,id
column as optional indicating that it is auto-generated, see the picture belowHere is a small video to give you a view from my perspective
https://github.com/zenstackhq/zenstack/assets/109352196/702b5b36-9552-452b-a30c-576e4b01a18f
An attempt to fix it
Trying to explicitly provide the create operation with an
id
results in broken codethrows the following error
As you can see,
id
was not inserted where it was supposed to go, insidecreate
object to join other fields liketype
,receiverId
andsenderId
. I have no idea how to fix it atmSetup