diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index cfa6b0e56c..336ad89504 100644 --- a/django/db/backends/mysql/base.py +++ b/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', diff --git a/django/db/backends/mysql_old/base.py b/django/db/backends/mysql_old/base.py index adfa03d569..48b6b6958a 100644 --- a/django/db/backends/mysql_old/base.py +++ b/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', diff --git a/tests/regressiontests/string_lookup/models.py b/tests/regressiontests/string_lookup/models.py index 1bdb2d4452..39e7955592 100644 --- a/tests/regressiontests/string_lookup/models.py +++ b/tests/regressiontests/string_lookup/models.py @@ -97,6 +97,12 @@ __test__ = {'API_TESTS': ur""" >>> Article.objects.get(text__exact='The quick brown fox jumps over the lazy dog.') +# 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.objects.get(text__contains='quick brown fox')