Ticket #593: fulltext.patch

File fulltext.patch, 3.5 KB (added by mrtact@…, 19 years ago)

Patch adding a "match" keyword that does full-text searching on mysql

  • core/db/__init__.py

     
    3636get_random_function_sql = dbmod.get_random_function_sql
    3737get_table_list = dbmod.get_table_list
    3838get_relations = dbmod.get_relations
     39get_fulltext_op_sql = dbmod.get_fulltext_op_sql
    3940OPERATOR_MAPPING = dbmod.OPERATOR_MAPPING
    4041DATA_TYPES = dbmod.DATA_TYPES
    4142DATA_TYPES_REVERSE = dbmod.DATA_TYPES_REVERSE
  • core/db/backends/ado_mssql.py

     
    115115def get_relations(cursor, table_name):
    116116    raise NotImplementedError
    117117
     118def get_fulltext_op_sql():
     119    raise NotImplementedError
     120
    118121OPERATOR_MAPPING = {
    119122    'exact': '=',
    120123    'iexact': 'LIKE',
  • core/db/backends/mysql.py

     
    127127def get_relations(cursor, table_name):
    128128    raise NotImplementedError
    129129
     130def get_fulltext_op_sql(**kwargs):
     131    return "match (%s%s) against ('%s' in boolean mode)"
     132
    130133OPERATOR_MAPPING = {
    131134    'exact': '=',
    132135    'iexact': 'LIKE',
  • core/db/backends/postgresql.py

     
    121121            continue
    122122    return relations
    123123
     124def get_fulltext_op_sql():
     125    raise NotImplementedError
     126
    124127# Register these custom typecasts, because Django expects dates/times to be
    125128# in Python's native (standard-library) datetime/time format, whereas psycopg
    126129# use mx.DateTime by default.
  • core/db/backends/sqlite3.py

     
    129129def get_relations(cursor, table_name):
    130130    raise NotImplementedError
    131131
     132def get_fulltext_op_sql():
     133        raise NotImplementedError
     134
    132135# Operators and fields ########################################################
    133136
    134137OPERATOR_MAPPING = {
  • core/meta/__init__.py

     
    10921092        return "%s = %%s" % db.get_date_extract_sql(lookup_type, table_prefix + field_name)
    10931093    elif lookup_type == 'isnull':
    10941094        return "%s%s IS %sNULL" % (table_prefix, field_name, (not value and 'NOT ' or ''))
     1095    elif lookup_type == 'match':
     1096        return db.get_fulltext_op_sql() % (table_prefix, field_name, value)
    10951097    raise TypeError, "Got invalid lookup_type: %s" % repr(lookup_type)
    10961098
    10971099def function_get_object(opts, klass, does_not_exist_exception, **kwargs):
  • core/meta/fields.py

     
    171171            return ["%s%%" % prep_for_like_query(value)]
    172172        elif lookup_type in ('endswith', 'iendswith'):
    173173            return ["%%%s" % prep_for_like_query(value)]
    174         elif lookup_type == 'isnull':
     174        elif lookup_type in ('isnull', 'match'):
    175175            return []
    176176        raise TypeError, "Field has invalid lookup: %s" % lookup_type
    177177
Back to Top