Unclear Introspection error message: Error parsing attribute "@id": Fields that are marked as id must be required.
See original GitHub issueIntrospecting SQLite:
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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Unclear Introspection error message: Error parsing attribute ...
Unclear Introspection error message : Error parsing attribute "@id": Fields that are marked as id must be required. #1368.
Read more >prisma introspect generate invalid model - Stack Overflow
@relation error msg in : Error parsing attribute "@relation": The type of the field userId in the model posts is not matching the...
Read more >GraphQL specification
In this query, the id , firstName , and lastName fields form a selection set. ... performed without losing information, then it must...
Read more >HTML Standard
This is why, for instance, it is non-conforming to have two id attributes with ... Errors that involve areas that affect authors migrating...
Read more >Error Codes and Descriptions - Travelport
0349, VAN transaction id: $? has been issued and cannot be cancelled or modified from ... 1006, Required attribute Queue Number in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 https://github.com/prisma/specs/issues/176#issuecomment-561289686 for context on autoincrement syntax.
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.