From c00a8525c6a003b57afbe6cdef243ffad397dcbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Tue, 23 Jul 2013 13:40:50 +0300 Subject: [PATCH] Fixed #20788 -- exclude() generated subquery failure "Fixed" by adding a test case, the original problem was already fixed by earlier ORM changes. Thanks to david@judicata.com for the report and test case. --- tests/queries/tests.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 87d54b637e..4bacd9a1cc 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -2910,7 +2910,7 @@ class DoubleInSubqueryTests(TestCase): self.assertQuerysetEqual( qs, [lfb1], lambda x: x) -class Ticket18785Tests(unittest.TestCase): +class Ticket18785Tests(TestCase): def test_ticket_18785(self): # Test join trimming from ticket18785 qs = Item.objects.exclude( @@ -2920,3 +2920,22 @@ class Ticket18785Tests(unittest.TestCase): ).order_by() self.assertEqual(1, str(qs.query).count('INNER JOIN')) self.assertEqual(0, str(qs.query).count('OUTER JOIN')) + + +class Ticket20788Tests(TestCase): + def test_ticket_20788(self): + Paragraph.objects.create() + paragraph = Paragraph.objects.create() + page = paragraph.page.create() + chapter = Chapter.objects.create(paragraph=paragraph) + Book.objects.create(chapter=chapter) + + paragraph2 = Paragraph.objects.create() + Page.objects.create() + chapter2 = Chapter.objects.create(paragraph=paragraph2) + book2 = Book.objects.create(chapter=chapter2) + + sentences_not_in_pub = Book.objects.exclude( + chapter__paragraph__page=page) + self.assertQuerysetEqual( + sentences_not_in_pub, [book2], lambda x: x)