diff options
| author | Adam Johnson <me@adamj.eu> | 2025-05-21 13:48:59 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-05-23 16:15:59 +0200 |
| commit | c2615a050036eda0bca090c707191076220cee9f (patch) | |
| tree | aeeefc43af5b18d29b4073a16470af2cd7713ce0 /tests/aggregation | |
| parent | b8e5a8a9a2a767f584cbe89a878a42363706f939 (diff) | |
Fixed #36405 -- Fixed Aggregate.order_by using OuterRef.
co-authored-by: Simon Charette <charette.s@gmail.com>
Diffstat (limited to 'tests/aggregation')
| -rw-r--r-- | tests/aggregation/tests.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 6d284da63d..1cf3a8f66e 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -2413,6 +2413,35 @@ class AggregateTestCase(TestCase): } self.assertEqual(values, expected_values) + @skipUnlessDBFeature("supports_aggregate_order_by_clause") + def test_string_agg_filter_outerref(self): + values = ( + Publisher.objects.annotate( + stringagg=Subquery( + Book.objects.annotate( + stringagg=StringAgg( + "name", + delimiter=Value(";"), + order_by=OuterRef("num_awards"), + ) + ).values("stringagg")[:1] + ) + ) + .values("stringagg") + .order_by("id") + ) + + self.assertQuerySetEqual( + values, + [ + { + "stringagg": "The Definitive Guide to Django: " + "Web Development Done Right" + } + ] + * 5, + ) + @skipUnlessDBFeature("supports_json_field", "supports_aggregate_order_by_clause") def test_string_agg_jsonfield_order_by(self): Employee.objects.bulk_create( |
