From c2615a050036eda0bca090c707191076220cee9f Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 21 May 2025 13:48:59 +0100 Subject: Fixed #36405 -- Fixed Aggregate.order_by using OuterRef. co-authored-by: Simon Charette --- tests/postgres_tests/test_aggregates.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/postgres_tests') diff --git a/tests/postgres_tests/test_aggregates.py b/tests/postgres_tests/test_aggregates.py index ae386b6659..621fa43d91 100644 --- a/tests/postgres_tests/test_aggregates.py +++ b/tests/postgres_tests/test_aggregates.py @@ -364,6 +364,18 @@ class TestGeneralAggregate(PostgreSQLTestCase): [[], [], [], []], ) + def test_array_agg_with_order_by_outer_ref(self): + StatTestModel.objects.annotate( + atm_ids=Subquery( + AggregateTestModel.objects.annotate( + ids=ArrayAgg( + "id", + order_by=[OuterRef("int1")], + ) + ).values("ids")[:1] + ) + ) + def test_bit_and_general(self): values = AggregateTestModel.objects.filter(integer_field__in=[0, 1]).aggregate( bitand=BitAnd("integer_field") -- cgit v1.3