mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
6d4b143786
commit
32d5c39016
|
@ -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)'
|
||||
|
|
|
@ -34,6 +34,12 @@ __test__ = {'API_TESTS':r"""
|
|||
>>> a7 = Article(headline='Article 7', pub_date=datetime(2005, 7, 27))
|
||||
>>> a7.save()
|
||||
|
||||
# text matching tests for PostgreSQL 8.3
|
||||
>>> Article.objects.filter(id__iexact='1')
|
||||
[<Article: Article 1>]
|
||||
>>> Article.objects.filter(pub_date__startswith='2005')
|
||||
[<Article: Article 5>, <Article: Article 6>, <Article: Article 4>, <Article: Article 2>, <Article: Article 3>, <Article: Article 7>, <Article: Article 1>]
|
||||
|
||||
# Each QuerySet gets iterator(), which is a generator that "lazily" returns
|
||||
# results using database-level iteration.
|
||||
>>> for a in Article.objects.iterator():
|
||||
|
|
Loading…
Reference in New Issue