summaryrefslogtreecommitdiff
path: root/tests/aggregation
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-04-06 08:19:53 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-04-07 06:57:32 +0200
commit9daf8b4109c3e133eb57349bb44d73cc60c5773c (patch)
treef5503798f3a605bbbc890dcfe345b6fe6214467e /tests/aggregation
parent1c7aed71ec70d4ef0c2cae6de9cee844d03e7054 (diff)
Fixed #34464 -- Fixed queryset aggregation over group by reference.
Regression in 59bea9efd2768102fc9d3aedda469502c218e9b7. Refs #28477. Thanks Ian Cubitt for the report.
Diffstat (limited to 'tests/aggregation')
-rw-r--r--tests/aggregation/tests.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index c1ae9f0dd5..ae68c24563 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -36,6 +36,7 @@ from django.db.models.functions import (
Greatest,
Least,
Lower,
+ Mod,
Now,
Pi,
TruncDate,
@@ -2175,3 +2176,9 @@ class AggregateAnnotationPruningTests(TestCase):
sql = ctx.captured_queries[0]["sql"].lower()
self.assertEqual(sql.count("select"), 2, "Subquery wrapping required")
self.assertEqual(sql.count("authors_count"), 2)
+
+ def test_referenced_group_by_annotation_kept(self):
+ queryset = Book.objects.values(pages_mod=Mod("pages", 10)).annotate(
+ mod_count=Count("*")
+ )
+ self.assertEqual(queryset.count(), 1)