#35234: ExclusionConstraint.expressions should be checked for foreign relationship
references
------------------------------------------------+--------------------------
Reporter: Simon Charette | Owner: (none)
Type: Cleanup/optimization | Status: assigned
Component: contrib.postgres | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+--------------------------
Unlike `CheckConstraint.condition`, `UniqueConstraint.fields`,
`.expressions`, and `.include` the `ExclusionConstraint.expressions`
members are not checked for references to foreign tables to emit
`models.E041` on violation which [
https://forum.djangoproject.com/t
/exclusionconstraint-with-expression-does-not-apply-migration/21574 has
been a source of confusion].
In order to avoid coupling the model constraint checks with third-party
application and allow any third-party application to provide their own
checks `Model._check_constraint` should delegate validation to
`BaseConstraint.check` like `_check_fields` delegates to `Field.check`.
Unfortunately `CheckConstraint` already defines a `.check` attribute which
I suggest we rename to `._check` internally (better name welcome) to avoid
collision with the proposed `BaseConstraint.check()` method and expose a
coherent interface.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35234>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.