Ticket #867: negation_lookup_type.patch

File negation_lookup_type.patch, 5.5 KB (added by Drew Amato <drewamato@…>, 18 years ago)

Patch: SVN diff between my changes and r1327

  • django_src/django/core/db/backends/ado_mssql.py

     
    117117
    118118OPERATOR_MAPPING = {
    119119    'exact': '= %s',
    120     'iexact': 'LIKE %s',
    121     'contains': 'LIKE %s',
    122     'icontains': 'LIKE %s',
     120    'iexact': 'LIKE %s',
     121    'inotexact': 'NOT LIKE %s'
     122    'contains': 'LIKE %s',
     123    'doesnotcontain': 'NOT LIKE %s',
     124    'icontains': 'LIKE %s',
     125    'idoesnotcontain': 'NOT LIKE %s',
    123126    'ne': '!= %s',
    124127    'gt': '> %s',
    125128    'gte': '>= %s',
    126129    'lt': '< %s',
    127130    'lte': '<= %s',
    128     'startswith': 'LIKE %s',
    129     'endswith': 'LIKE %s',
    130     'istartswith': 'LIKE %s',
    131     'iendswith': 'LIKE %s',
     131    'startswith': 'LIKE %s',
     132    'doesnotstartwith': 'NOT LIKE %s',
     133    'endswith': 'LIKE %s',
     134    'doesnotendwith': 'NOT LIKE %s',
     135    'istartswith': 'LIKE %s',
     136    'idoesnotstartwith': 'NOT LIKE %s',
     137    'iendswith': 'LIKE %s',
     138    'idoesnotendwith': 'NOT LIKE %s',
    132139}
    133140
    134141DATA_TYPES = {
  • django_src/django/core/db/backends/postgresql.py

     
    134134
    135135OPERATOR_MAPPING = {
    136136    'exact': '= %s',
    137     'iexact': 'ILIKE %s',
    138     'contains': 'LIKE %s',
    139     'icontains': 'ILIKE %s',
     137    'iexact': 'ILIKE %s',
     138    'inotexact': 'NOT ILIKE %s',
     139    'contains': 'LIKE %s',
     140    'doesnotcontain': 'NOT LIKE %s'
     141    'icontains': 'ILIKE %s',
     142    'idoesnotcontain': 'NOT ILIKE %s'
    140143    'ne': '!= %s',
    141144    'gt': '> %s',
    142145    'gte': '>= %s',
    143146    'lt': '< %s',
    144147    'lte': '<= %s',
    145     'startswith': 'LIKE %s',
    146     'endswith': 'LIKE %s',
    147     'istartswith': 'ILIKE %s',
    148     'iendswith': 'ILIKE %s',
     148    'startswith': 'LIKE %s',
     149    'doesnotstartwith': 'NOT LIKE %s',
     150    'endswith': 'LIKE %s',
     151    'doesnotendwith': 'NOT LIKE %s'
     152    'istartswith': 'ILIKE %s',
     153    'idoesnotstartwith': 'NOT ILIKE %s',
     154    'iendswith': 'ILIKE %s',
     155    'idoesnotendwith': 'NOT ILIKE %s',
    149156}
    150157
    151158# This dictionary maps Field objects to their associated PostgreSQL column
  • django_src/django/core/db/backends/sqlite3.py

     
    137137OPERATOR_MAPPING = {
    138138    'exact': '= %s',
    139139    'iexact': "LIKE %s ESCAPE '\\'",
     140    'inotexact': "NOT LIKE %s ESCAPE '\\'",
    140141    'contains': "LIKE %s ESCAPE '\\'",
     142    'doesnotcontain': "NOT LIKE %s ESCAPE '\\'",
    141143    'icontains': "LIKE %s ESCAPE '\\'",
     144    'idoesnotcontain': "NOT LIKE %s ESCAPE '\\'",
    142145    'ne': '!= %s',
    143146    'gt': '> %s',
    144147    'gte': '>= %s',
    145148    'lt': '< %s',
    146149    'lte': '<= %s',
    147150    'startswith': "LIKE %s ESCAPE '\\'",
     151    'doesnotstartwith': "NOT LIKE %s ESCAPE '\\'",
    148152    'endswith': "LIKE %s ESCAPE '\\'",
     153    'doesnotendwith': "NOT LIKE %s ESCAPE '\\'",
    149154    'istartswith': "LIKE %s ESCAPE '\\'",
     155    'idoesnotstartwith': "NOT LIKE %s ESCAPE '\\'",
    150156    'iendswith': "LIKE %s ESCAPE '\\'",
     157    'idoesnotendwith': "NOT LIKE %s ESCAPE '\\'",
    151158}
    152159
    153160# SQLite doesn't actually support most of these types, but it "does the right
  • django_src/django/core/db/backends/mysql.py

     
    130130OPERATOR_MAPPING = {
    131131    'exact': '= %s',
    132132    'iexact': 'LIKE %s',
     133    'inotexact': 'NOT LIKE %s',
    133134    'contains': 'LIKE BINARY %s',
     135    'doesnotcontain': 'NOT LIKE BINARY %s',
    134136    'icontains': 'LIKE %s',
     137    'idoesnotcontain': 'NOT LIKE %s',
    135138    'ne': '!= %s',
    136139    'gt': '> %s',
    137140    'gte': '>= %s',
    138141    'lt': '< %s',
    139142    'lte': '<= %s',
    140143    'startswith': 'LIKE BINARY %s',
     144    'doesnotstartwith' : 'NOT LIKE BINARY %s',
    141145    'endswith': 'LIKE BINARY %s',
     146    'doesnotendwith' : 'NOT LIKE BINARY %s',
    142147    'istartswith': 'LIKE %s',
     148    'idoesnotstartwith' : 'NOT LIKE %s',
    143149    'iendswith': 'LIKE %s',
     150    'idoesnotendwith' : 'NOT LIKE %s',
    144151}
    145152
    146153# This dictionary maps Field objects to their associated MySQL column
  • django_src/django/core/meta/fields.py

     
    163163            return value
    164164        elif lookup_type == 'year':
    165165            return ['%s-01-01' % value, '%s-12-31' % value]
    166         elif lookup_type in ('contains', 'icontains'):
     166        elif lookup_type in ('contains', 'icontains', 'doesnotcontain', 'idoesnotcontain'):
    167167            return ["%%%s%%" % prep_for_like_query(value)]
    168         elif lookup_type == 'iexact':
     168        elif lookup_type in ('iexact', 'inotexact'):
    169169            return [prep_for_like_query(value)]
    170         elif lookup_type in ('startswith', 'istartswith'):
     170        elif lookup_type in ('startswith', 'istartswith', 'doesnotstartwith', 'idoesnotstartwith'):
    171171            return ["%s%%" % prep_for_like_query(value)]
    172         elif lookup_type in ('endswith', 'iendswith'):
     172        elif lookup_type in ('endswith', 'iendswith', 'doesnotendwith', 'idoesnotendwith'):
    173173            return ["%%%s" % prep_for_like_query(value)]
    174174        elif lookup_type == 'isnull':
    175175            return []
Back to Top