diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 91edf71aeb2..28c858557b4 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -64,6 +64,7 @@ class Annotation(models.Model): class ExtraInfo(models.Model): info = models.CharField(max_length=100) note = models.ForeignKey(Note) + value = models.IntegerField(null=True) class Meta: ordering = ['info'] diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py index 34bfea0b944..82a8de08beb 100644 --- a/tests/regressiontests/queries/tests.py +++ b/tests/regressiontests/queries/tests.py @@ -52,8 +52,8 @@ class Queries1Tests(BaseQuerysetTest): # Create these out of order so that sorting by 'id' will be different to sorting # by 'info'. Helps detect some problems later. - self.e2 = ExtraInfo.objects.create(info='e2', note=n2) - e1 = ExtraInfo.objects.create(info='e1', note=self.n1) + self.e2 = ExtraInfo.objects.create(info='e2', note=n2, value=41) + e1 = ExtraInfo.objects.create(info='e1', note=self.n1, value=42) self.a1 = Author.objects.create(name='a1', num=1001, extra=e1) self.a2 = Author.objects.create(name='a2', num=2002, extra=e1) @@ -1106,6 +1106,13 @@ class Queries1Tests(BaseQuerysetTest): self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 1) self.assertTrue(str(q3.query).count('INNER JOIN') == 0) + def test_ticket19672(self): + self.assertQuerysetEqual( + Report.objects.filter(Q(creator__isnull=False) & + ~Q(creator__extra__value=41)), + [''] + ) + class Queries2Tests(TestCase): def setUp(self):