1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #34975 -- Fixed crash of conditional aggregate() over aggregations.

Adjustments made to solve_lookup_type to defer the resolving of
references for summarized aggregates failed to account for similar
requirements for lookup values which can also reference annotations
through Aggregate.filter.

Regression in b181cae2e3.

Refs #25307.

Thanks Sergey Nesterenko for the report.
This commit is contained in:
Simon Charette
2023-11-17 19:42:44 -05:00
committed by Mariusz Felisiak
parent 594873befb
commit 7530cf3900
3 changed files with 13 additions and 2 deletions

View File

@@ -2309,3 +2309,9 @@ class AggregateAnnotationPruningTests(TestCase):
aggregate,
{"sum_avg_publisher_pages": 1100.0, "books_count": 2},
)
def test_aggregate_reference_lookup_rhs(self):
aggregates = Author.objects.annotate(
max_book_author=Max("book__authors"),
).aggregate(count=Count("id", filter=Q(id=F("max_book_author"))))
self.assertEqual(aggregates, {"count": 1})