summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorIan Foote <python@ian.feete.org>2020-11-15 22:43:47 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-11-27 20:42:04 +0100
commit8b040e3cbbb2e81420e777afc3ca48a1c8f4dd5a (patch)
tree32ed8b5456c9ce569643a1ebb34491a1c9b6fa01 /tests/postgres_tests/test_array.py
parente46ca51c249677c52e04db28fc0c60ae1948b3b2 (diff)
downloaddjango-8b040e3cbbb2e81420e777afc3ca48a1c8f4dd5a.tar.gz
Fixed #25534, Fixed #31639 -- Added support for transform references in expressions.
Thanks Mariusz Felisiak and Simon Charette for reviews.
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(