Ticket #8102: 8102-2.diff

File 8102-2.diff, 1.0 KB (added by Karen Tracey, 16 years ago)

Cast exact lookups to CHAR before specifying COLLATE to avoid problems with specifying collate on numeric/binary columns

  • django/db/backends/mysql/base.py

     
    145145    features = DatabaseFeatures()
    146146    ops = DatabaseOperations()
    147147    operators = {
    148         'exact': '= BINARY %s',
     148        'exact': '= CAST(%s AS CHAR) COLLATE UTF8_BIN',
    149149        'iexact': 'LIKE %s',
    150         'contains': 'LIKE BINARY %s',
     150        'contains': 'LIKE %s COLLATE UTF8_BIN',
    151151        'icontains': 'LIKE %s',
    152         'regex': 'REGEXP BINARY %s',
     152        'regex': 'REGEXP %s COLLATE UTF8_BIN',
    153153        'iregex': 'REGEXP %s',
    154154        'gt': '> %s',
    155155        'gte': '>= %s',
    156156        'lt': '< %s',
    157157        'lte': '<= %s',
    158         'startswith': 'LIKE BINARY %s',
    159         'endswith': 'LIKE BINARY %s',
     158        'startswith': 'LIKE %s COLLATE UTF8_BIN',
     159        'endswith': 'LIKE %s COLLATE UTF8_BIN',
    160160        'istartswith': 'LIKE %s',
    161161        'iendswith': 'LIKE %s',
    162162    }
Back to Top