Django

Code

Changeset 1326

Show
Ignore:
Timestamp:
11/20/05 20:46:15 (2 years ago)
Author:
adrian
Message:

Fixed #800 -- Fixed bug in treatement of underscores and percent signs in SQLite backend. In order to do this, changed OPERATOR_MAPPING in DB backends to include a format string of the field value, because ESCAPE comes after the field value.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/db/backends/ado_mssql.py

    r1316 r1326  
    117117 
    118118OPERATOR_MAPPING = { 
    119     'exact': '=', 
    120     'iexact': 'LIKE', 
    121     'contains': 'LIKE', 
    122     'icontains': 'LIKE', 
    123     'ne': '!=', 
    124     'gt': '>', 
    125     'gte': '>=', 
    126     'lt': '<', 
    127     'lte': '<=', 
    128     'startswith': 'LIKE', 
    129     'endswith': 'LIKE', 
    130     'istartswith': 'LIKE', 
    131     'iendswith': 'LIKE', 
     119    'exact': '= %s', 
     120    'iexact': 'LIKE %s', 
     121    'contains': 'LIKE %s', 
     122    'icontains': 'LIKE %s', 
     123    'ne': '!= %s', 
     124    'gt': '> %s', 
     125    'gte': '>= %s', 
     126    'lt': '< %s', 
     127    'lte': '<= %s', 
     128    'startswith': 'LIKE %s', 
     129    'endswith': 'LIKE %s', 
     130    'istartswith': 'LIKE %s', 
     131    'iendswith': 'LIKE %s', 
    132132} 
    133133 
  • django/trunk/django/core/db/backends/mysql.py

    r1316 r1326  
    129129 
    130130OPERATOR_MAPPING = { 
    131     'exact': '=', 
    132     'iexact': 'LIKE', 
    133     'contains': 'LIKE BINARY', 
    134     'icontains': 'LIKE', 
    135     'ne': '!=', 
    136     'gt': '>', 
    137     'gte': '>=', 
    138     'lt': '<', 
    139     'lte': '<=', 
    140     'startswith': 'LIKE BINARY', 
    141     'endswith': 'LIKE BINARY', 
    142     'istartswith': 'LIKE', 
    143     'iendswith': 'LIKE', 
     131    'exact': '= %s', 
     132    'iexact': 'LIKE %s', 
     133    'contains': 'LIKE BINARY %s', 
     134    'icontains': 'LIKE %s', 
     135    'ne': '!= %s', 
     136    'gt': '> %s', 
     137    'gte': '>= %s', 
     138    'lt': '< %s', 
     139    'lte': '<= %s', 
     140    'startswith': 'LIKE BINARY %s', 
     141    'endswith': 'LIKE BINARY %s', 
     142    'istartswith': 'LIKE %s', 
     143    'iendswith': 'LIKE %s', 
    144144} 
    145145 
  • django/trunk/django/core/db/backends/postgresql.py

    r1316 r1326  
    134134 
    135135OPERATOR_MAPPING = { 
    136     'exact': '=', 
    137     'iexact': 'ILIKE', 
    138     'contains': 'LIKE', 
    139     'icontains': 'ILIKE', 
    140     'ne': '!=', 
    141     'gt': '>', 
    142     'gte': '>=', 
    143     'lt': '<', 
    144     'lte': '<=', 
    145     'startswith': 'LIKE', 
    146     'endswith': 'LIKE', 
    147     'istartswith': 'ILIKE', 
    148     'iendswith': 'ILIKE', 
     136    'exact': '= %s', 
     137    'iexact': 'ILIKE %s', 
     138    'contains': 'LIKE %s', 
     139    'icontains': 'ILIKE %s', 
     140    'ne': '!= %s', 
     141    'gt': '> %s', 
     142    'gte': '>= %s', 
     143    'lt': '< %s', 
     144    'lte': '<= %s', 
     145    'startswith': 'LIKE %s', 
     146    'endswith': 'LIKE %s', 
     147    'istartswith': 'ILIKE %s', 
     148    'iendswith': 'ILIKE %s', 
    149149} 
    150150 
  • django/trunk/django/core/db/backends/sqlite3.py

    r1316 r1326  
    132132# Operators and fields ######################################################## 
    133133 
     134# SQLite requires LIKE statements to include an ESCAPE clause if the value 
     135# being escaped has a percent or underscore in it. 
     136# See http://www.sqlite.org/lang_expr.html for an explanation. 
    134137OPERATOR_MAPPING = { 
    135     'exact':        '=', 
    136     'iexact':       'LIKE'
    137     'contains':     'LIKE'
    138     'icontains':    'LIKE'
    139     'ne':           '!=', 
    140     'gt':           '>', 
    141     'gte':          '>=', 
    142     'lt':           '<', 
    143     'lte':          '<=', 
    144     'startswith':   'LIKE'
    145     'endswith':     'LIKE'
    146     'istartswith': 'LIKE'
    147     'iendswith':    'LIKE'
     138    'exact': '= %s', 
     139    'iexact': "LIKE %s ESCAPE '\\'"
     140    'contains': "LIKE %s ESCAPE '\\'"
     141    'icontains': "LIKE %s ESCAPE '\\'"
     142    'ne': '!= %s', 
     143    'gt': '> %s', 
     144    'gte': '>= %s', 
     145    'lt': '< %s', 
     146    'lte': '<= %s', 
     147    'startswith': "LIKE %s ESCAPE '\\'"
     148    'endswith': "LIKE %s ESCAPE '\\'"
     149    'istartswith': "LIKE %s ESCAPE '\\'"
     150    'iendswith': "LIKE %s ESCAPE '\\'"
    148151} 
    149152 
  • django/trunk/django/core/meta/__init__.py

    r1319 r1326  
    11281128    field_name = db.db.quote_name(field_name) 
    11291129    try: 
    1130         return '%s%s %s %%s' % (table_prefix, field_name, db.OPERATOR_MAPPING[lookup_type]
     1130        return '%s%s %s' % (table_prefix, field_name, (db.OPERATOR_MAPPING[lookup_type] % '%s')
    11311131    except KeyError: 
    11321132        pass