#31530: Check that CheckConstraint.check and UniqueConstraint.condition don't
span
joins.
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* stage: Unreviewed => Accepted
Old description:
> Similar to #31410 but for `check` and `condition`.
>
> ---
>
> Not everyone is familiar with the fact database level constraint cannot
> span across tables and might be tempted to do
>
> {{{#!python
> class Person(models.Model):
> age = models.PositiveSmallIntegerField()
> parent = models.ForeignKey(self)
>
> class Meta:
> constraints = {
> CheckConstraint(
> name='age_lt_parent', check=Q(age__lt=parent__age)
> ),
> }
> }}}
>
> Which we'll happily create migrations for but we'll then crash because we
> prevent JOINs when resolving `check`.
New description:
Similar to #31410 but for `check` and `condition`.
----
Not everyone is familiar with the fact database level constraint cannot
span across tables and might be tempted to do
{{{#!python
class Person(models.Model):
age = models.PositiveSmallIntegerField()
parent = models.ForeignKey(self)
class Meta:
constraints = {
CheckConstraint(
name='age_lt_parent', check=Q(age__lt=parent__age)
),
}
}}}
Which we'll happily create migrations for but we'll then crash because we
prevent JOINs when resolving `check`.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/31530#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.220955a11eded0d7a7bff81457152d74%40djangoproject.com.