Fixed #20250 - Added a regression test for negated Q + annotate

Thanks nott.
This commit is contained in:
Tim Graham 2013-05-29 08:48:02 -04:00
parent 8a6e040bfa
commit 7426e72302
1 changed files with 11 additions and 0 deletions

View File

@ -1111,6 +1111,17 @@ class Queries1Tests(BaseQuerysetTest):
['<Report: r1>']
)
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,
['<Author: a1>', '<Author: a2>', '<Author: a3>', '<Author: a4>']
)
class Queries2Tests(TestCase):
def setUp(self):