summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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 8caefc060c..a8ce6ed1d8 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -2210,6 +2210,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"))