From 78a2617703bc1dada409f126db5c3db214913ff4 Mon Sep 17 00:00:00 2001 From: Anssi Kääriäinen Date: Mon, 20 Jan 2014 18:28:16 +0200 Subject: Fixed #21787 -- regression in MTI .exclude() queries --- tests/queries/tests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests') diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 03cfc71afe..b303d5f603 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -3225,3 +3225,21 @@ class ValuesJoinPromotionTests(TestCase): self.assertEqual(qs.count(), 1) tblname = connection.ops.quote_name(ObjectB._meta.db_table) self.assertTrue(' LEFT OUTER JOIN %s' % tblname in str(qs.query)) + + +class ForeignKeyToBaseExcludeTests(TestCase): + def test_ticket_21787(self): + sc1 = SpecialCategory.objects.create(special_name='sc1', name='sc1') + sc2 = SpecialCategory.objects.create(special_name='sc2', name='sc2') + sc3 = SpecialCategory.objects.create(special_name='sc3', name='sc3') + c1 = CategoryItem.objects.create(category=sc1) + CategoryItem.objects.create(category=sc2) + self.assertQuerysetEqual( + SpecialCategory.objects.exclude( + categoryitem__id=c1.pk).order_by('name'), + [sc2, sc3], lambda x: x + ) + self.assertQuerysetEqual( + SpecialCategory.objects.filter(categoryitem__id=c1.pk), + [sc1], lambda x: x + ) -- cgit v1.3