From 4f138fe5a496a81115c4fba6615a517fc62c3b17 Mon Sep 17 00:00:00 2001 From: Matthew Wilkes Date: Thu, 2 Jun 2016 11:05:25 -0700 Subject: Fixed #22288 -- Fixed F() expressions with the __range lookup. --- tests/postgres_tests/test_array.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/postgres_tests/test_array.py') diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py index 6dd1fb85e0..2b5796dc6f 100644 --- a/tests/postgres_tests/test_array.py +++ b/tests/postgres_tests/test_array.py @@ -173,12 +173,40 @@ class TestQuerying(PostgreSQLTestCase): self.objs[:2] ) + @unittest.expectedFailure + def test_in_including_F_object(self): + # This test asserts that Array objects passed to filters can be + # constructed to contain F objects. This currently doesn't work as the + # psycopg2 mogrify method that generates the ARRAY() syntax is + # expecting literals, not column references (#27095). + self.assertSequenceEqual( + NullableIntegerArrayModel.objects.filter(field__in=[[models.F('id')]]), + self.objs[:2] + ) + + def test_in_as_F_object(self): + self.assertSequenceEqual( + NullableIntegerArrayModel.objects.filter(field__in=[models.F('field')]), + self.objs[:4] + ) + def test_contained_by(self): self.assertSequenceEqual( NullableIntegerArrayModel.objects.filter(field__contained_by=[1, 2]), self.objs[:2] ) + @unittest.expectedFailure + def test_contained_by_including_F_object(self): + # This test asserts that Array objects passed to filters can be + # constructed to contain F objects. This currently doesn't work as the + # psycopg2 mogrify method that generates the ARRAY() syntax is + # expecting literals, not column references (#27095). + self.assertSequenceEqual( + NullableIntegerArrayModel.objects.filter(field__contained_by=[models.F('id'), 2]), + self.objs[:2] + ) + def test_contains(self): self.assertSequenceEqual( NullableIntegerArrayModel.objects.filter(field__contains=[2]), -- cgit v1.3