mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
[5.0.x] 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 inb181cae2e3. Refs #25307. Thanks Sergey Nesterenko for the report. Backport of7530cf3900from main
This commit is contained in:
committed by
Mariusz Felisiak
parent
8fb92dc96a
commit
49f1ced863
@@ -2300,3 +2300,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})
|
||||
|
||||
Reference in New Issue
Block a user