mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #36405 -- Fixed Aggregate.order_by using OuterRef.
co-authored-by: Simon Charette <charette.s@gmail.com>
This commit is contained in:
committed by
Sarah Boyce
parent
b8e5a8a9a2
commit
c2615a0500
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user