Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #2170 -- "exact" lookups in MySQL are now case-sensitive (the s…

…ame 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
  • Loading branch information...
commit 8e816c8304051eb45e5fae05d8fab0254a6259ec 1 parent 52cc11c
@malcolmt malcolmt authored
View
2  django/db/backends/mysql/base.py
@@ -135,7 +135,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
features = DatabaseFeatures()
ops = DatabaseOperations()
operators = {
- 'exact': '= %s',
+ 'exact': '= BINARY %s',
'iexact': 'LIKE %s',
'contains': 'LIKE BINARY %s',
'icontains': 'LIKE %s',
View
2  django/db/backends/mysql_old/base.py
@@ -139,7 +139,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
features = DatabaseFeatures()
ops = DatabaseOperations()
operators = {
- 'exact': '= %s',
+ 'exact': '= BINARY %s',
'iexact': 'LIKE %s',
'contains': 'LIKE BINARY %s',
'icontains': 'LIKE %s',
View
6 tests/regressiontests/string_lookup/models.py
@@ -97,6 +97,12 @@ def __str__(self):
>>> Article.objects.get(text__exact='The quick brown fox jumps over the lazy dog.')
<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: Article Test>
Please sign in to comment.
Something went wrong with that request. Please try again.