Opened 18 years ago

Last modified 15 years ago

#2170 closed defect

db lookup methods not case sensitive on mysql — at Version 3

Reported by: derelm Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by James Bennett)

i noticed that the methods field__exact and field__iexact match case insensitive on mysql
given you have a field (choices=(('a','small a'),('A','capital a'))) field__exact will always match both choices.

possible solution:
in django.db.backends.mysql.base

OPERATOR_MAPPING = {
    'exact': '= BINARY %s',
    ...
}

oh and will iexact, icontains, istatswith, iendswith all match exactly the same rows anyways?

Change History (4)

comment:1 by Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedAccepted

by Matt McClanahan <cardinal@…>, 17 years ago

Attachment: 2170-1.diff added

comment:2 by Matt McClanahan <cardinal@…>, 17 years ago

Has patch: set

This came up in IRC today, when somebody noted that it's resulting in an exception if you do FooModel.objects.get(charfield='foo') and have both 'foo' and 'Foo' in that field (Two rows returned instead of one as expected).

comment:3 by James Bennett, 17 years ago

Description: modified (diff)

Fixing formatting in description.

Note: See TracTickets for help on using tickets.
Back to Top