Fixed #28749 -- Added subquery support for ArrayField's __in lookup.
This commit is contained in:
parent
6e8508734b
commit
e554b72a2a
|
@ -242,6 +242,9 @@ class ArrayLenTransform(Transform):
|
||||||
class ArrayInLookup(In):
|
class ArrayInLookup(In):
|
||||||
def get_prep_lookup(self):
|
def get_prep_lookup(self):
|
||||||
values = super().get_prep_lookup()
|
values = super().get_prep_lookup()
|
||||||
|
if hasattr(self.rhs, '_prepare'):
|
||||||
|
# Subqueries don't need further preparation.
|
||||||
|
return values
|
||||||
# In.process_rhs() expects values to be hashable, so convert lists
|
# In.process_rhs() expects values to be hashable, so convert lists
|
||||||
# to tuples.
|
# to tuples.
|
||||||
prepared_values = []
|
prepared_values = []
|
||||||
|
|
|
@ -176,6 +176,15 @@ class TestQuerying(PostgreSQLTestCase):
|
||||||
self.objs[:2]
|
self.objs[:2]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_in_subquery(self):
|
||||||
|
IntegerArrayModel.objects.create(field=[2, 3])
|
||||||
|
self.assertSequenceEqual(
|
||||||
|
NullableIntegerArrayModel.objects.filter(
|
||||||
|
field__in=IntegerArrayModel.objects.all().values_list('field', flat=True)
|
||||||
|
),
|
||||||
|
self.objs[2:3]
|
||||||
|
)
|
||||||
|
|
||||||
@unittest.expectedFailure
|
@unittest.expectedFailure
|
||||||
def test_in_including_F_object(self):
|
def test_in_including_F_object(self):
|
||||||
# This test asserts that Array objects passed to filters can be
|
# This test asserts that Array objects passed to filters can be
|
||||||
|
|
Loading…
Reference in New Issue