summaryrefslogtreecommitdiff
path: root/tests/aggregation
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-04-02 23:20:53 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2025-04-03 18:35:11 +0200
commit317690403a40fbaf52c6abcbc8d39f199c9b5102 (patch)
tree86712887d4edec68c0a459ac6273519cbedc4b61 /tests/aggregation
parentcd458eac2704232474ef549e902a33908414c815 (diff)
[5.2.x] Fixed #36292 -- Fixed crash when aggregating over a group mixing transforms and references.
Regression in 65ad4ade74dc9208b9d686a451cd6045df0c9c3a. Refs #28900 Thanks Patrick Altman for the report. Backport of 543e17c4405dfdac4f18759fc78b190406d14239 from main
Diffstat (limited to 'tests/aggregation')
-rw-r--r--tests/aggregation/tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index 861b2c5dfc..bf44c4d25f 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -2162,6 +2162,33 @@ class AggregateTestCase(TestCase):
},
)
+ def test_group_by_transform_column(self):
+ self.assertSequenceEqual(
+ Store.objects.values(
+ "original_opening__date",
+ "name",
+ )
+ .annotate(Count("books"))
+ .order_by("name"),
+ [
+ {
+ "original_opening__date": datetime.date(1994, 4, 23),
+ "name": "Amazon.com",
+ "books__count": 6,
+ },
+ {
+ "original_opening__date": datetime.date(2001, 3, 15),
+ "name": "Books.com",
+ "books__count": 4,
+ },
+ {
+ "original_opening__date": datetime.date(1945, 4, 25),
+ "name": "Mamma and Pappa's Books",
+ "books__count": 3,
+ },
+ ],
+ )
+
def test_group_by_reference_subquery(self):
author_qs = (
Author.objects.annotate(publisher_id=F("book__publisher"))