summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-12-08 02:03:14 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-12-12 05:51:33 +0100
commitb0ad41198b3e333f57351e3fce5a1fb47f23f376 (patch)
treeb68005963b6261679db534b102d4327b584d12e2 /tests/postgres_tests/test_array.py
parentfcf95e592774a6ededec35481a2061474d467a2b (diff)
Fixed #34013 -- Added QuerySet.order_by() support for annotation transforms.
Thanks Eugene Morozov and Ben Nace for the reports.
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 48b03c626a..8aaa7be077 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -469,6 +469,16 @@ class TestQuerying(PostgreSQLTestCase):
self.assertIn("GROUP BY 2", sql)
self.assertIn("ORDER BY 2", sql)
+ def test_order_by_arrayagg_index(self):
+ qs = (
+ NullableIntegerArrayModel.objects.values("order")
+ .annotate(ids=ArrayAgg("id"))
+ .order_by("-ids__0")
+ )
+ self.assertQuerySetEqual(
+ qs, [{"order": obj.order, "ids": [obj.id]} for obj in reversed(self.objs)]
+ )
+
def test_index(self):
self.assertSequenceEqual(
NullableIntegerArrayModel.objects.filter(field__0=2), self.objs[1:3]