[1.11.x] Fixed #28038 -- Restored casting to text of builtin lookups on PostgreSQL.
Reverted658f1e8
which broke code using __icontains's implicit cast to ::text on ArrayField. Thanks Peter J. Farrell for the report. Backport ofa354c69055
from master
This commit is contained in:
parent
f9d2a20d7b
commit
5d35e8eb06
|
@ -83,8 +83,6 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
'istartswith', 'endswith', 'iendswith', 'regex', 'iregex'):
|
||||
if internal_type in ('IPAddressField', 'GenericIPAddressField'):
|
||||
lookup = "HOST(%s)"
|
||||
elif internal_type in ('CharField', 'TextField'):
|
||||
lookup = '%s'
|
||||
else:
|
||||
lookup = "%s::text"
|
||||
|
||||
|
|
|
@ -12,3 +12,6 @@ Bugfixes
|
|||
* Made migrations respect ``Index``’s ``name`` argument. If you created a
|
||||
named index with Django 1.11, ``makemigrations`` will create a migration to
|
||||
recreate the index with the correct name (:ticket:`28051`).
|
||||
|
||||
* Fixed a crash when using a ``__icontains`` lookup on a ``ArrayField``
|
||||
(:ticket:`28038`).
|
||||
|
|
|
@ -216,6 +216,14 @@ class TestQuerying(PostgreSQLTestCase):
|
|||
self.objs[1:3]
|
||||
)
|
||||
|
||||
def test_icontains(self):
|
||||
# Using the __icontains lookup with ArrayField is inefficient.
|
||||
instance = CharArrayModel.objects.create(field=['FoO'])
|
||||
self.assertSequenceEqual(
|
||||
CharArrayModel.objects.filter(field__icontains='foo'),
|
||||
[instance]
|
||||
)
|
||||
|
||||
def test_contains_charfield(self):
|
||||
# Regression for #22907
|
||||
self.assertSequenceEqual(
|
||||
|
|
Loading…
Reference in New Issue