Ticket #593: matchoperator.diff

File matchoperator.diff, 3.6 KB (added by Tim Keating, 18 years ago)

Match operator implementation for full text search (on MySQL only, other backends raise NotImplemented)

  • core/db/__init__.py

     
    3737get_table_list = dbmod.get_table_list
    3838get_table_description = dbmod.get_table_description
    3939get_relations = dbmod.get_relations
     40get_fulltext_op_sql = dbmod.get_fulltext_op_sql
    4041OPERATOR_MAPPING = dbmod.OPERATOR_MAPPING
    4142DATA_TYPES = dbmod.DATA_TYPES
    4243DATA_TYPES_REVERSE = dbmod.DATA_TYPES_REVERSE
  • core/db/backends/ado_mssql.py

     
    118118def get_relations(cursor, table_name):
    119119    raise NotImplementedError
    120120
     121def get_fulltext_op_sql():
     122    raise NotImplementedError
     123
    121124OPERATOR_MAPPING = {
    122125    'exact': '= %s',
    123126    'iexact': 'LIKE %s',
  • core/db/backends/mysql.py

     
    132132def get_relations(cursor, table_name):
    133133    raise NotImplementedError
    134134
     135def get_fulltext_op_sql(**kwargs):
     136    return "match (%s%s) against ('%s' in boolean mode)"
     137
    135138OPERATOR_MAPPING = {
    136139    'exact': '= %s',
    137140    'iexact': 'LIKE %s',
  • core/db/backends/postgresql.py

     
    126126            continue
    127127    return relations
    128128
     129def get_fulltext_op_sql():
     130    raise NotImplementedError
     131
    129132# Register these custom typecasts, because Django expects dates/times to be
    130133# in Python's native (standard-library) datetime/time format, whereas psycopg
    131134# use mx.DateTime by default.
  • core/db/backends/sqlite3.py

     
    134134def get_relations(cursor, table_name):
    135135    raise NotImplementedError
    136136
     137def get_fulltext_op_sql():
     138        raise NotImplementedError
     139
    137140# Operators and fields ########################################################
    138141
    139142# SQLite requires LIKE statements to include an ESCAPE clause if the value
  • core/meta/__init__.py

     
    13491349        return "%s = %%s" % db.get_date_extract_sql(lookup_type, table_prefix + field_name)
    13501350    elif lookup_type == 'isnull':
    13511351        return "%s%s IS %sNULL" % (table_prefix, field_name, (not value and 'NOT ' or ''))
     1352    elif lookup_type == 'match':
     1353        return db.get_fulltext_op_sql() % (table_prefix, field_name, value)
    13521354    raise TypeError, "Got invalid lookup_type: %s" % repr(lookup_type)
    13531355
    13541356def function_get_object(opts, klass, does_not_exist_exception, **kwargs):
  • core/meta/fields.py

     
    189189            return ["%s%%" % prep_for_like_query(value)]
    190190        elif lookup_type in ('endswith', 'iendswith'):
    191191            return ["%%%s" % prep_for_like_query(value)]
    192         elif lookup_type == 'isnull':
     192        elif lookup_type in ('isnull', 'match'):
    193193            return []
    194194        raise TypeError, "Field has invalid lookup: %s" % lookup_type
    195195
Back to Top