﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31530	Check that CheckConstraint.check and UniqueConstraint.condition don't span joins.	Simon Charette	nobody	"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`."	Cleanup/optimization	new	Database layer (models, ORM)	3.0	Normal				Accepted	0	0	0	0	0	0
