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.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 27ccf18581..3c7584e84c 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -434,6 +434,13 @@ class TestQuerying(PostgreSQLTestCase):
self.objs[:1],
)
+ def test_index_annotation(self):
+ qs = NullableIntegerArrayModel.objects.annotate(second=models.F('field__1'))
+ self.assertCountEqual(
+ qs.values_list('second', flat=True),
+ [None, None, None, 3, 30],
+ )
+
def test_overlap(self):
self.assertSequenceEqual(
NullableIntegerArrayModel.objects.filter(field__overlap=[1, 2]),
@@ -495,6 +502,15 @@ class TestQuerying(PostgreSQLTestCase):
self.objs[2:3],
)
+ def test_slice_annotation(self):
+ qs = NullableIntegerArrayModel.objects.annotate(
+ first_two=models.F('field__0_2'),
+ )
+ self.assertCountEqual(
+ qs.values_list('first_two', flat=True),
+ [None, [1], [2], [2, 3], [20, 30]],
+ )
+
def test_usage_in_subquery(self):
self.assertSequenceEqual(
NullableIntegerArrayModel.objects.filter(