Ticket #8553: mysql_soundslike.diff

File mysql_soundslike.diff, 1.7 KB (added by dacort <django@…>, 16 years ago)

MySQL "sounds like" (soundex) support

  • django/db/models/sql/constants.py

     
    44QUERY_TERMS = dict([(x, None) for x in (
    55    'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in',
    66    'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year',
    7     'month', 'day', 'isnull', 'search', 'regex', 'iregex',
     7    'month', 'day', 'isnull', 'search', 'regex', 'iregex', 'soundslike',
    88    )])
    99
    1010# Size of each "chunk" for get_iterator calls.
  • django/db/models/fields/__init__.py

     
    219219            return ["%%%s%%" % connection.ops.prep_for_like_query(value)]
    220220        elif lookup_type == 'iexact':
    221221            return [connection.ops.prep_for_like_query(value)]
     222        elif lookup_type == 'soundslike':
     223            return [connection.ops.prep_for_like_query(value)]
    222224        elif lookup_type in ('startswith', 'istartswith'):
    223225            return ["%s%%" % connection.ops.prep_for_like_query(value)]
    224226        elif lookup_type in ('endswith', 'iendswith'):
  • django/db/backends/mysql/base.py

     
    163163        'endswith': 'LIKE BINARY %s',
    164164        'istartswith': 'LIKE %s',
    165165        'iendswith': 'LIKE %s',
     166        'soundslike': 'SOUNDS LIKE %s',
    166167    }
    167168
    168169    def __init__(self, **kwargs):
Back to Top