summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
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]