summaryrefslogtreecommitdiff
path: root/tests/annotations
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-09-15 11:40:59 +0200
committerGitHub <noreply@github.com>2020-09-15 11:40:59 +0200
commiteaf9764d3bb25970da89de5799d8d308715628ba (patch)
tree3bb6ad00878ce5bfbc65e0ae33c9604df820af4b /tests/annotations
parent7be6a6a4d665061e8bc6a741b16ff92353f5d19e (diff)
Fixed #32007 -- Fixed queryset crash with Q() annotation and aggregation.
Thanks Gordon Wrigley for the report. Regression in 8a6df55f2dd5131282084a4edfd48f63fbf8c69a.
Diffstat (limited to 'tests/annotations')
-rw-r--r--tests/annotations/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
index 3d00a02a11..a2bbb95e47 100644
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -183,6 +183,17 @@ class NonAggregateAnnotationTestCase(TestCase):
self.assertEqual(book.combined, 13410.0)
self.assertEqual(book.rating_count, 1)
+ def test_q_expression_annotation_with_aggregation(self):
+ book = Book.objects.filter(isbn='159059725').annotate(
+ isnull_pubdate=ExpressionWrapper(
+ Q(pubdate__isnull=True),
+ output_field=BooleanField(),
+ ),
+ rating_count=Count('rating'),
+ ).first()
+ self.assertEqual(book.isnull_pubdate, False)
+ self.assertEqual(book.rating_count, 1)
+
def test_aggregate_over_annotation(self):
agg = Author.objects.annotate(other_age=F('age')).aggregate(otherage_sum=Sum('other_age'))
other_agg = Author.objects.aggregate(age_sum=Sum('age'))