Ticket #21376: 21376_test.diff

File 21376_test.diff, 1.4 KB (added by Tim Graham, 11 years ago)
  • tests/queries/models.py

    diff --git a/tests/queries/models.py b/tests/queries/models.py
    index ec924c0..cc952e8 100644
    a b class ObjectB(models.Model):  
    412412@python_2_unicode_compatible
    413413class ObjectC(models.Model):
    414414    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)
    417417
    418418    def __str__(self):
    419419        return self.name
  • tests/queries/tests.py

    diff --git a/tests/queries/tests.py b/tests/queries/tests.py
    index d1e9bd7..5628eb4 100644
    a b class ValuesJoinPromotionTests(TestCase):  
    31893189    def test_non_nullable_fk_not_promoted(self):
    31903190        qs = ObjectB.objects.values('objecta__name')
    31913191        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))
Back to Top