Fixed #2170 -- "exact" lookups in MySQL are now case-sensitive (the same as other backends).
This is a backwards incompatible change if you were relying on 'exact' being case-insensitive. For that, you should be using 'iexact'. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7798 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
52cc11c4e2
commit
8e816c8304
|
@ -135,7 +135,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
features = DatabaseFeatures()
|
features = DatabaseFeatures()
|
||||||
ops = DatabaseOperations()
|
ops = DatabaseOperations()
|
||||||
operators = {
|
operators = {
|
||||||
'exact': '= %s',
|
'exact': '= BINARY %s',
|
||||||
'iexact': 'LIKE %s',
|
'iexact': 'LIKE %s',
|
||||||
'contains': 'LIKE BINARY %s',
|
'contains': 'LIKE BINARY %s',
|
||||||
'icontains': 'LIKE %s',
|
'icontains': 'LIKE %s',
|
||||||
|
|
|
@ -139,7 +139,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
features = DatabaseFeatures()
|
features = DatabaseFeatures()
|
||||||
ops = DatabaseOperations()
|
ops = DatabaseOperations()
|
||||||
operators = {
|
operators = {
|
||||||
'exact': '= %s',
|
'exact': '= BINARY %s',
|
||||||
'iexact': 'LIKE %s',
|
'iexact': 'LIKE %s',
|
||||||
'contains': 'LIKE BINARY %s',
|
'contains': 'LIKE BINARY %s',
|
||||||
'icontains': 'LIKE %s',
|
'icontains': 'LIKE %s',
|
||||||
|
|
|
@ -97,6 +97,12 @@ __test__ = {'API_TESTS': ur"""
|
||||||
>>> Article.objects.get(text__exact='The quick brown fox jumps over the lazy dog.')
|
>>> Article.objects.get(text__exact='The quick brown fox jumps over the lazy dog.')
|
||||||
<Article: Article Test>
|
<Article: Article Test>
|
||||||
|
|
||||||
|
# Regression tests for #2170: test case sensitiveness
|
||||||
|
>>> Article.objects.filter(text__exact='tHe qUick bRown fOx jUmps over tHe lazy dog.')
|
||||||
|
[]
|
||||||
|
>>> Article.objects.filter(text__iexact='tHe qUick bRown fOx jUmps over tHe lazy dog.')
|
||||||
|
[<Article: Article Test>]
|
||||||
|
|
||||||
>>> Article.objects.get(text__contains='quick brown fox')
|
>>> Article.objects.get(text__contains='quick brown fox')
|
||||||
<Article: Article Test>
|
<Article: Article Test>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue