From 32d5c39016f7f14dfc19142d78d944d92eb9cd70 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 8 Aug 2008 20:09:53 +0000 Subject: Fixed #6523 -- Use the correct cast on field types for PostgreSQL when searching within a field column (e.g. "like", "contains", etc). Required for PostgreSQL 8.3. Thanks to Dan Watson for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8242 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/backends/postgresql/operations.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'django') diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index ba6e3235c2..de7b5a9520 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -35,6 +35,12 @@ class DatabaseOperations(BaseDatabaseOperations): def deferrable_sql(self): return " DEFERRABLE INITIALLY DEFERRED" + def lookup_cast(self, lookup_type): + if lookup_type in ('iexact', 'contains', 'icontains', 'startswith', 'istartswith', + 'endswith', 'iendswith'): + return "%s::text" + return "%s" + def field_cast_sql(self, db_type): if db_type == 'inet': return 'HOST(%s)' -- cgit v1.3