summaryrefslogtreecommitdiff
path: root/tests/aggregation/tests.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-05-21 23:49:05 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-05-23 06:25:27 +0200
commit2ee01747c32a7275a7a1a5f7862acba7db764921 (patch)
tree7a668fab0cc6996f7491fbe988500d0ee1f81992 /tests/aggregation/tests.py
parent89f10a80d7e681cd0cccf22d932e380f51bd3524 (diff)
Refs #34551 -- Fixed QuerySet.aggregate() crash on precending aggregation reference.
Regression in 1297c0d0d76a708017fe196b61a0ab324df76954. Refs #31679.
Diffstat (limited to 'tests/aggregation/tests.py')
-rw-r--r--tests/aggregation/tests.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index ae68c24563..5135458668 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -1260,7 +1260,7 @@ class AggregateTestCase(TestCase):
self.assertEqual(author.sum_age, other_author.sum_age)
def test_aggregate_over_aggregate(self):
- msg = "Cannot resolve keyword 'age_agg' into field."
+ msg = "Cannot compute Avg('age_agg'): 'age_agg' is an aggregate"
with self.assertRaisesMessage(FieldError, msg):
Author.objects.aggregate(
age_agg=Sum(F("age")),
@@ -2102,12 +2102,17 @@ class AggregateTestCase(TestCase):
)
self.assertEqual(len(qs), 6)
- def test_aggregation_over_annotation_shared_alias(self):
+ def test_multiple_aggregate_references(self):
+ aggregates = Author.objects.aggregate(
+ total_books=Count("book"),
+ coalesced_total_books=Coalesce("total_books", 0),
+ )
self.assertEqual(
- Publisher.objects.annotate(agg=Count("book__authors")).aggregate(
- agg=Count("agg"),
- ),
- {"agg": 5},
+ aggregates,
+ {
+ "total_books": 10,
+ "coalesced_total_books": 10,
+ },
)