diff options
| author | Mads Jensen <mje@inducks.org> | 2017-11-14 22:51:51 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-29 11:12:07 -0500 |
| commit | 3545e844885608932a692d952c12cd863e2320b5 (patch) | |
| tree | 68fbeaff7e4309a76184fc15bd38fe7f15caca76 /django | |
| parent | 899999db4293d40613626833860de28e8ccdd413 (diff) | |
[1.11.x] Fixed #28702 -- Made query lookups for CIText fields use citext.
Backport of f0a68c25118786d47041d0a435b2afa953be3c86 from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/postgres/fields/citext.py | 6 | ||||
| -rw-r--r-- | django/db/backends/postgresql/operations.py | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/django/contrib/postgres/fields/citext.py b/django/contrib/postgres/fields/citext.py index 42660001ae..f5ef86c586 100644 --- a/django/contrib/postgres/fields/citext.py +++ b/django/contrib/postgres/fields/citext.py @@ -3,7 +3,11 @@ from django.db.models import CharField, EmailField, TextField __all__ = ['CICharField', 'CIEmailField', 'CIText', 'CITextField'] -class CIText: +class CIText(object): + + def get_internal_type(self): + return 'CI' + super(CIText, self).get_internal_type() + def db_type(self, connection): return 'citext' diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index a66cb0c563..f220639725 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -83,6 +83,8 @@ class DatabaseOperations(BaseDatabaseOperations): 'istartswith', 'endswith', 'iendswith', 'regex', 'iregex'): if internal_type in ('IPAddressField', 'GenericIPAddressField'): lookup = "HOST(%s)" + elif internal_type in ('CICharField', 'CIEmailField', 'CITextField'): + lookup = '%s::citext' else: lookup = "%s::text" |
