You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unclear Introspection error message: Error parsing attribute "@id": Fields that are marked as id must be required. #1368
CREATE TABLE "playlist_track" (
"PlaylistId" INTEGER NOT NULL,
"TrackId" INTEGER NOT NULL,
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
FOREIGN KEY("PlaylistId") REFERENCES "playlists"("PlaylistId") ON DELETE NO ACTION ON UPDATE NO ACTION,
FOREIGN KEY("TrackId") REFERENCES "tracks"("TrackId") ON DELETE NO ACTION ON UPDATE NO ACTION
)
Creates error message:
ERROR Oops, an unexpected error occured!
Schema parsing
error: Error parsing attribute "@id": Fields that are marked as id must be required.
--> schema.prisma:126
|
125 | TrackId tracks
126 | id Int? @id
|
Error message does not include name of table/model for context.
The consequence of inferring Integer PKs as Autoincrement NOT NULL (or as it would look like in the schema.prisma file: Int @id @default(autoincrement())) is that the id would be optional when writing, and non-null when reading.
This can only occur on SQLite since only there are optional id fields valid DDL. Models with an optional Id will now be marked as @@ignore during introspection and won't cause a validation error. If a model is handwritten with an optional id and without @@ignore, you'll still get the same validation error which is then clear enough.
Activity
janpio commentedon Jan 30, 2020
Problem: No NOT NULL on
id.janpio commentedon Feb 4, 2020
Investigation into how SQLite works:
Create a table with this SQL:
Executing
INSERT INTO testing (id) VALUES (NULL)creates a column with theidfilled with the next auto increment value.Decision
Integer PKs should therefore be inferred as Autoincrement NOT NULL.
sorenbs commentedon Feb 4, 2020
For clarification:
The consequence of inferring Integer PKs as Autoincrement NOT NULL (or as it would look like in the schema.prisma file:
Int @id @default(autoincrement())) is that the id would be optional when writing, and non-null when reading.DECISION: this is excellent!
See also prisma/specs#176 (comment) for context on autoincrement syntax.
15 remaining items
tomhoule commentedon Feb 11, 2021
This will probably lead to an
@@ignoreon the model now, but work. To be confirmed.tomhoule commentedon Feb 17, 2021
Scheduling for this release to confirm that
@@ignorefixes this.do4gr commentedon Mar 18, 2021
This can only occur on SQLite since only there are optional id fields valid DDL. Models with an optional Id will now be marked as @@ignore during introspection and won't cause a validation error. If a model is handwritten with an optional id and without @@ignore, you'll still get the same validation error which is then clear enough.