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
feat(validation): disallow SetNull
referential action on required referenced fields
#3298
Conversation
SetNull
referential action on optional referenced fields
SetNull
referential action on optional referenced fieldsSetNull
referential action on required referenced fields
…tion with at least a SetNull referential action
psl/psl/tests/validation/relations/set_null_is_not_valid_on_mixed_fields.prisma
Show resolved
Hide resolved
psl/psl/tests/validation/relations/set_null_is_not_valid_on_required_fields.prisma
Show resolved
Hide resolved
psl/psl/tests/validation/relations/set_null_is_not_valid_on_required_fields.prisma
Show resolved
Hide resolved
psl/psl/tests/validation/relations/set_null_is_not_valid_on_mixed_fields.prisma
Show resolved
Hide resolved
introspection-engine/introspection-engine-tests/tests/re_introspection/vitess.rs
Outdated
Show resolved
Hide resolved
…ehavior in 'referential_actions_are_kept_intact' test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me though, let's confirm with someone with more knowledge in the engines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nitpicks, also somebody from the @prisma/client-team-rust should ack the removed tests.
psl/psl-core/src/validate/validation_pipeline/validations/relations.rs
Outdated
Show resolved
Hide resolved
psl/psl-core/src/validate/validation_pipeline/validations/relations.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed tests make sense to me considering the new validation rule 👍
Note: let's monitor introspection-ci later |
See introspection-ci results https://prisma-company.slack.com/archives/C01778YKS00/p1666686897741579 |
This PR validates against required fields referenced by a relation with at least one
SetNull
referential action, regardless of whether it appears inonUpdate
oronDelete
.E.g., with the following schema,
this PR introduces the following validation error:
Note: the only SQL database we support which would accept the DDL declaration equivalent to the Prisma schema above is Postgres, although it would still fail at runtime when the
SET NULL
referential action is triggered.This PR, however, introduces this new validation regardless of the used database connector. See internal doc for more details. It should be noted that Tom has expressed some concerns on validating against something that Postgres actually supports (although we argue that Postgres' support in this case is a bug).
Closes prisma/prisma#14673.