-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] extended tables do not preserve @id
's @default(autoincrement())
#1520
Labels
Comments
Must be the duplicate of/similar to #1518. |
Hi @piscopancer , do you mind sharing the definition of the |
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Spotify_b1Qqq9RHPS.mp4
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
The text was updated successfully, but these errors were encountered: