Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Malcolm Tredinnick authored June 30, 2008
2  django/db/backends/mysql/base.py
@@ -135,7 +135,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
135 135
     features = DatabaseFeatures()
136 136
     ops = DatabaseOperations()
137 137
     operators = {
138  
-        'exact': '= %s',
  138
+        'exact': '= BINARY %s',
139 139
         'iexact': 'LIKE %s',
140 140
         'contains': 'LIKE BINARY %s',
141 141
         'icontains': 'LIKE %s',
2  django/db/backends/mysql_old/base.py
@@ -139,7 +139,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
139 139
     features = DatabaseFeatures()
140 140
     ops = DatabaseOperations()
141 141
     operators = {
142  
-        'exact': '= %s',
  142
+        'exact': '= BINARY %s',
143 143
         'iexact': 'LIKE %s',
144 144
         'contains': 'LIKE BINARY %s',
145 145
         'icontains': 'LIKE %s',
6  tests/regressiontests/string_lookup/models.py
@@ -97,6 +97,12 @@ def __str__(self):
97 97
 >>> Article.objects.get(text__exact='The quick brown fox jumps over the lazy dog.')
98 98
 <Article: Article Test>
99 99
 
  100
+# Regression tests for #2170: test case sensitiveness
  101
+>>> Article.objects.filter(text__exact='tHe qUick bRown fOx jUmps over tHe lazy dog.')
  102
+[]
  103
+>>> Article.objects.filter(text__iexact='tHe qUick bRown fOx jUmps over tHe lazy dog.')
  104
+[<Article: Article Test>]
  105
+
100 106
 >>> Article.objects.get(text__contains='quick brown fox')
101 107
 <Article: Article Test>
102 108
 

0 notes on commit 8e816c8

Please sign in to comment.
Something went wrong with that request. Please try again.