diff --git a/tests/queries/models.py b/tests/queries/models.py
index ec924c0..cc952e8 100644
a
|
b
|
class ObjectB(models.Model):
|
412 | 412 | @python_2_unicode_compatible |
413 | 413 | class ObjectC(models.Model): |
414 | 414 | name = models.CharField(max_length=50) |
415 | | objecta = models.ForeignKey(ObjectA) |
416 | | objectb = models.ForeignKey(ObjectB) |
| 415 | objecta = models.ForeignKey(ObjectA, null=True) |
| 416 | objectb = models.ForeignKey(ObjectB, null=True) |
417 | 417 | |
418 | 418 | def __str__(self): |
419 | 419 | return self.name |
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index d1e9bd7..5628eb4 100644
a
|
b
|
class ValuesJoinPromotionTests(TestCase):
|
3189 | 3189 | def test_non_nullable_fk_not_promoted(self): |
3190 | 3190 | qs = ObjectB.objects.values('objecta__name') |
3191 | 3191 | self.assertTrue(' INNER JOIN ' in str(qs.query)) |
| 3192 | |
| 3193 | def test_ticket_21376(self): |
| 3194 | # fails after ecaba3602837d1e02fe1e961f7d3bf9086453259 |
| 3195 | # LEFT OUTER JOIN below is now INNER JOIN |
| 3196 | a = ObjectA.objects.create() |
| 3197 | c = ObjectC.objects.create(objecta=a) |
| 3198 | qs = ObjectC.objects.filter( |
| 3199 | Q(objecta=a) | Q(objectb__objecta=a), |
| 3200 | ).filter( |
| 3201 | Q(objectb=1) | Q(objecta=a), |
| 3202 | ) |
| 3203 | self.assertEqual(qs.count(), 1) |
| 3204 | self.assertTrue(' LEFT OUTER JOIN "queries_objectb"' in str(qs.query)) |