summaryrefslogtreecommitdiff
path: root/tests
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 15:38:04 +0100
commit7530cf3900ab98104edcde69e8a2a415e82b345a (patch)
treeb0b2d30e5f1849be26aa6203453907a17f498111 /tests
parent594873befbbec13a2d9a048a361757dd3cf178da (diff)
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.
Diffstat (limited to 'tests')
-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 a073d01590..af6c660cf1 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -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})