Ticket #966: notlike.diff

File notlike.diff, 3.5 KB (added by hugo, 10 years ago)

add notcontains and friends

  • core/db/backends/ado_mssql.py

     
    132132    'endswith': 'LIKE %s',
    133133    'istartswith': 'LIKE %s',
    134134    'iendswith': 'LIKE %s',
     135    'notcontains': 'NOT LIKE %s',
     136    'notstartswith': 'NOT LIKE %s',
     137    'notendswith': 'NOT LIKE %s',
     138    'inotcontains': 'NOT LIKE %s',
     139    'inotstartswith': 'NOT LIKE %s',
     140    'inotendswith': 'NOT LIKE %s',
    135141}
    136142
    137143DATA_TYPES = {
  • core/db/backends/postgresql.py

     
    151151    'endswith': 'LIKE %s',
    152152    'istartswith': 'ILIKE %s',
    153153    'iendswith': 'ILIKE %s',
     154    'notcontains': 'NOT LIKE %s',
     155    'notstartswith': 'NOT LIKE %s',
     156    'notendswith': 'NOT LIKE %s',
     157    'inotcontains': 'NOT ILIKE %s',
     158    'inotstartswith': 'NOT ILIKE %s',
     159    'inotendswith': 'NOT ILIKE %s',
    154160}
    155161
    156162# This dictionary maps Field objects to their associated PostgreSQL column
  • core/db/backends/sqlite3.py

     
    153153    'endswith': "LIKE %s ESCAPE '\\'",
    154154    'istartswith': "LIKE %s ESCAPE '\\'",
    155155    'iendswith': "LIKE %s ESCAPE '\\'",
     156    'notcontains': "NOT LIKE %s ESCAPE '\\'",
     157    'notstartswith': "NOT LIKE %s ESCAPE '\\'",
     158    'notendswith': "NOT LIKE %s ESCAPE '\\'",
     159    'inotcontains': "NOT LIKE %s ESCAPE '\\'",
     160    'inotstartswith': "NOT LIKE %s ESCAPE '\\'",
     161    'inotendswith': "NOT LIKE %s ESCAPE '\\'",
    156162}
    157163
    158164# SQLite doesn't actually support most of these types, but it "does the right
  • core/db/backends/mysql.py

     
    146146    'endswith': 'LIKE BINARY %s',
    147147    'istartswith': 'LIKE %s',
    148148    'iendswith': 'LIKE %s',
     149    'notcontains': 'NOT LIKE BINARY %s',
     150    'notstartswith': 'NOT LIKE BINARY %s',
     151    'notendswith': 'NOT LIKE BINARY %s',
     152    'inotcontains': 'NOT LIKE %s',
     153    'inotstartswith': 'NOT LIKE %s',
     154    'inotendswith': 'NOT LIKE %s',
    149155}
    150156
    151157# This dictionary maps Field objects to their associated MySQL column
  • core/meta/fields.py

     
    181181            return value
    182182        elif lookup_type == 'year':
    183183            return ['%s-01-01' % value, '%s-12-31' % value]
    184         elif lookup_type in ('contains', 'icontains'):
     184        elif lookup_type in ('contains', 'icontains', 'notcontains', 'inotcontains'):
    185185            return ["%%%s%%" % prep_for_like_query(value)]
    186186        elif lookup_type == 'iexact':
    187187            return [prep_for_like_query(value)]
    188         elif lookup_type in ('startswith', 'istartswith'):
     188        elif lookup_type in ('startswith', 'istartswith', 'notstartswith', 'inotstartswith'):
    189189            return ["%s%%" % prep_for_like_query(value)]
    190         elif lookup_type in ('endswith', 'iendswith'):
     190        elif lookup_type in ('endswith', 'iendswith', 'notendswith', 'inotendswith'):
    191191            return ["%%%s" % prep_for_like_query(value)]
    192192        elif lookup_type == 'isnull':
    193193            return []
Back to Top