diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-08-28 05:42:05 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-08-28 05:42:05 +0000 |
| commit | 71dda1918408a5b15d27c5b2cd28fddcd747449d (patch) | |
| tree | d362d05cae2b2b402b022a838a6ac894e7d3bb3b /django | |
| parent | f749b84824fc11f2f57d5b0036a07ead13fd1a99 (diff) | |
Fixed #8597 -- Allow the use of strings containing underscores and percentage
signs in "iexact" queries on PostgreSQL again (this case was missed in [8536]).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8646 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/__init__.py | 4 | ||||
| -rw-r--r-- | django/db/backends/postgresql/operations.py | 2 | ||||
| -rw-r--r-- | django/db/models/fields/__init__.py | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 074fa0ed70..be7aac4c03 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -301,6 +301,10 @@ class BaseDatabaseOperations(object): from django.utils.encoding import smart_unicode return smart_unicode(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_") + # Same as prep_for_like_query(), but called for "iexact" matches, which + # need not necessarily be implemented using "LIKE" in the backend. + prep_for_iexact_query = prep_for_like_query + def value_to_db_date(self, value): """ Transform a date value to an object compatible with what is expected diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index 01cc1fc8b7..235210939f 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -142,3 +142,5 @@ class DatabaseOperations(BaseDatabaseOperations): def savepoint_rollback_sql(self, sid): return "ROLLBACK TO SAVEPOINT %s" % sid + def prep_for_iexact_query(self, x): + return x diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 5c21e7db73..d3fb27b948 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -205,7 +205,7 @@ class Field(object): elif lookup_type in ('contains', 'icontains'): return ["%%%s%%" % connection.ops.prep_for_like_query(value)] elif lookup_type == 'iexact': - return [connection.ops.prep_for_like_query(value)] + return [connection.ops.prep_for_iexact_query(value)] elif lookup_type in ('startswith', 'istartswith'): return ["%s%%" % connection.ops.prep_for_like_query(value)] elif lookup_type in ('endswith', 'iendswith'): |
