diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 2d6fc0b008..d28291f340 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -1111,6 +1111,17 @@ class Queries1Tests(BaseQuerysetTest): [''] ) + def test_ticket_20250(self): + # A negated Q along with an annotated queryset failed in Django 1.4 + qs = Author.objects.annotate(Count('item')) + qs = qs.filter(~Q(extra__value=0)) + + self.assertTrue('SELECT' in str(qs.query)) + self.assertQuerysetEqual( + qs, + ['', '', '', ''] + ) + class Queries2Tests(TestCase): def setUp(self):