mirror of
https://github.com/django/django.git
synced 2025-11-20 11:36:04 +00:00
Fixed #34464 -- Fixed queryset aggregation over group by reference.
Regression in 59bea9efd2.
Refs #28477.
Thanks Ian Cubitt for the report.
This commit is contained in:
parent
1c7aed71ec
commit
9daf8b4109
3 changed files with 13 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue