summaryrefslogtreecommitdiff
path: root/tests/annotations/tests.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-11 11:29:14 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-12 07:20:06 +0200
commitaeb8996a6706cad3e96d8221760c1cb408ee7ed9 (patch)
tree678c5f77b6eb2b550dd6051b05c0d3ae78326cbd /tests/annotations/tests.py
parent5776a1660e54a95159164414829738b665c89916 (diff)
Fixed #31659 -- Made ExpressionWrapper preserve output_field for combined expressions.
Regression in df32fd42b84cc6dbba173201f244491b0d154a63. Thanks Simon Charette for the review.
Diffstat (limited to 'tests/annotations/tests.py')
-rw-r--r--tests/annotations/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
index c1ac0516ac..9f35074934 100644
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -170,6 +170,14 @@ class NonAggregateAnnotationTestCase(TestCase):
self.assertEqual(book.is_book, 1)
self.assertEqual(book.rating_count, 1)
+ def test_combined_expression_annotation_with_aggregation(self):
+ book = Book.objects.annotate(
+ combined=ExpressionWrapper(Value(3) * Value(4), output_field=IntegerField()),
+ rating_count=Count('rating'),
+ ).first()
+ self.assertEqual(book.combined, 12)
+ 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'))