Ticket #12583: postgres_typecast_fix_and_test.diff

File postgres_typecast_fix_and_test.diff, 2.6 KB (added by Ubercore, 14 years ago)
  • django/db/backends/postgresql/base.py

     
    7171class DatabaseWrapper(BaseDatabaseWrapper):
    7272    operators = {
    7373        'exact': '= %s',
    74         'iexact': '= UPPER(%s)',
    75         'contains': 'LIKE %s',
    76         'icontains': 'LIKE UPPER(%s)',
     74        'iexact': '= UPPER(%s::text)',
     75        'contains': 'LIKE %s::text',
     76        'icontains': 'LIKE UPPER(%s::text)',
    7777        'regex': '~ %s',
    7878        'iregex': '~* %s',
    7979        'gt': '> %s',
    8080        'gte': '>= %s',
    8181        'lt': '< %s',
    8282        'lte': '<= %s',
    83         'startswith': 'LIKE %s',
    84         'endswith': 'LIKE %s',
    85         'istartswith': 'LIKE UPPER(%s)',
    86         'iendswith': 'LIKE UPPER(%s)',
     83        'startswith': 'LIKE %s::text',
     84        'endswith': 'LIKE %s::text',
     85        'istartswith': 'LIKE UPPER(%s::text)',
     86        'iendswith': 'LIKE UPPER(%s::text)',
    8787    }
    8888
    8989    def __init__(self, *args, **kwargs):
  • django/db/backends/postgresql_psycopg2/base.py

     
    4444class DatabaseWrapper(BaseDatabaseWrapper):
    4545    operators = {
    4646        'exact': '= %s',
    47         'iexact': '= UPPER(%s)',
    48         'contains': 'LIKE %s',
    49         'icontains': 'LIKE UPPER(%s)',
     47        'iexact': '= UPPER(%s::text)',
     48        'contains': 'LIKE %s::text',
     49        'icontains': 'LIKE UPPER(%s::text)',
    5050        'regex': '~ %s',
    5151        'iregex': '~* %s',
    5252        'gt': '> %s',
    5353        'gte': '>= %s',
    5454        'lt': '< %s',
    5555        'lte': '<= %s',
    56         'startswith': 'LIKE %s',
    57         'endswith': 'LIKE %s',
    58         'istartswith': 'LIKE UPPER(%s)',
    59         'iendswith': 'LIKE UPPER(%s)',
     56        'startswith': 'LIKE %s::text',
     57        'endswith': 'LIKE %s::text',
     58        'istartswith': 'LIKE UPPER(%s::text)',
     59        'iendswith': 'LIKE UPPER(%s::text)',
    6060    }
    6161
    6262    def __init__(self, *args, **kwargs):
  • tests/regressiontests/queries/models.py

     
    12201220>>> subq._result_cache is None
    12211221True
    12221222
     1223# Regression test for #12583:
     1224>>> Tag(name="4").save()
     1225>>> Tag.objects.filter(name__iexact=4)
     1226[<Tag: 4>]
     1227
    12231228"""}
    12241229
    12251230# In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__
Back to Top