NullConstraintViolation
See original GitHub issueI have the following models (simplified for reporting the issue):
model User {
id String @default(cuid()) @id @unique
email String @unique
staff Staff?
}
model Staff {
id String @default(cuid()) @id @unique
user User
active Boolean?
}
When trying to add a user with the following query
mutation {
createOneUser (data: {
email: "user@gmail.com"
}) {
id
email
}
}
I get the following error
"error": "ConnectorError(NullConstraintViolation { field_name: \"User.staff\" })"
This seems odd, since the staff
field in the User
model is optional. I have other 1-1 relations with the same problem.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Null constraint violation on the fields: (`id`) · Issue #498 - GitHub
Bug description Unable to use @default(autoincrement()). Keep getting PrismaClientKnownRequestError: Invalid `client.user.create()` ...
Read more >null value in column violates not-null constraint PostgreSQL
1 Answer 1 · ERROR: column "v_id" is in a primary key SQL state: 42P16 · i can't fill records in v_id because...
Read more >Integrity constraint violation: 19 NOT NULL constraint failed
Hi everyone, I'm very new to laravel, this is my first project and I need little help. I'm getting this error but I'm...
Read more >How to Solve Not Null Constraint Violation in Target Table?
If we disable the constraint for target table to do the bulk load instead of normal load , and target table gets some...
Read more >Bizzarre insert behavior: NULL constraint violation with non ...
Bizzarre insert behavior: NULL constraint violation with non-null value, column changes every run. 393 views.
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
Thanks, I can confirm all of this. Most of them related to the query engine so I am going to transfer this issue.
I can no longer reproduce any of these conditions now with
prisma2@2.0.0-preview-5, binary version: 29f6d9f7f6d0a85cc30df1809733612bab56a1c5
These have been fixed between the updates