#31530: Check that CheckConstraint.check and UniqueConstraint.condition don't 
span
joins.
-------------------------------------+-------------------------------------
               Reporter:  Simon      |          Owner:  nobody
  Charette                           |
                   Type:             |         Status:  new
  Cleanup/optimization               |
              Component:  Database   |        Version:  3.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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>
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/052.b15138581beec9740ee41c6b221c67c5%40djangoproject.com.

Reply via email to