summaryrefslogtreecommitdiff
path: root/tests/aggregation
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-11-17 19:42:44 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-11-18 16:53:24 +0100
commitacf4cee95144c55a12492cdd71fa795d7accfe26 (patch)
treec4edecd96e42fa44c77ee6df2560a5641a4036e1 /tests/aggregation
parent47f9b8dca16b1fdc054b338d81eb080eabad0edf (diff)
[4.2.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 in b181cae2e3697b2e53b5b67ac67e59f3b05a6f0d. Refs #25307. Thanks Sergey Nesterenko for the report. Backport of 7530cf3900ab98104edcde69e8a2a415e82b345a from main
Diffstat (limited to 'tests/aggregation')
-rw-r--r--tests/aggregation/tests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index 8d8e46e312..48266d9774 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -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})