Ticket #3575: django_db.diff

File django_db.diff, 1.5 KB (added by Jack Moffitt <metajack@…>, 17 years ago)

patch to make iexact searches use LOWER() instead of ILIKE

  • django/db/models/query.py

     
    636636    if table_prefix.endswith('.'):
    637637        table_prefix = backend.quote_name(table_prefix[:-1])+'.'
    638638    field_name = backend.quote_name(field_name)
     639    # Grab mapping for table and column name to do formatting
     640    column_map = '%s%s' % (table_prefix, field_name)
     641    if hasattr(backend, 'COLUMN_MAPPING') and backend.COLUMN_MAPPING.has_key(lookup_type):
     642        column_map = backend.COLUMN_MAPPING[lookup_type] % column_map
    639643    try:
    640         return '%s%s %s' % (table_prefix, field_name, (backend.OPERATOR_MAPPING[lookup_type] % '%s'))
     644        return '%s %s' % (column_map, (backend.OPERATOR_MAPPING[lookup_type] % '%s'))
    641645    except KeyError:
    642646        pass
    643647    if lookup_type == 'in':
  • django/db/backends/postgresql_psycopg2/base.py

     
    120120def get_pk_default_value():
    121121    return "DEFAULT"
    122122
     123# Create a map for to do column functions
     124COLUMN_MAPPING = {
     125    'iexact': 'LOWER(%s)',
     126    }
     127
    123128OPERATOR_MAPPING = {
    124129    'exact': '= %s',
    125     'iexact': 'ILIKE %s',
     130    'iexact': '= LOWER(%s)',
    126131    'contains': 'LIKE %s',
    127132    'icontains': 'ILIKE %s',
    128133    'gt': '> %s',
Back to Top