1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #31530 -- Added test for joined OneToOneField in CheckConstraint.check

This commit is contained in:
Hasan Ramezani 2021-04-13 11:49:13 +02:00 committed by Mariusz Felisiak
parent 59552bea57
commit 33abc55601

View File

@ -1778,6 +1778,7 @@ class ConstraintsTests(TestCase):
field2 = models.PositiveSmallIntegerField() field2 = models.PositiveSmallIntegerField()
field3 = models.PositiveSmallIntegerField() field3 = models.PositiveSmallIntegerField()
parent = models.ForeignKey('self', models.CASCADE) parent = models.ForeignKey('self', models.CASCADE)
previous = models.OneToOneField('self', models.CASCADE, related_name='next')
class Meta: class Meta:
constraints = [ constraints = [
@ -1792,9 +1793,18 @@ class ConstraintsTests(TestCase):
models.CheckConstraint( models.CheckConstraint(
name='name3', check=models.Q(parent__field3=models.F('field1')) name='name3', check=models.Q(parent__field3=models.F('field1'))
), ),
models.CheckConstraint(
name='name4', check=models.Q(name=Lower('previous__name')),
),
] ]
joined_fields = ['parent__field1', 'parent__field2', 'parent__field3', 'parent__name'] joined_fields = [
'parent__field1',
'parent__field2',
'parent__field3',
'parent__name',
'previous__name',
]
errors = Model.check(databases=self.databases) errors = Model.check(databases=self.databases)
expected_errors = [ expected_errors = [
Error( Error(