From 8e816c8304051eb45e5fae05d8fab0254a6259ec Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 30 Jun 2008 10:25:35 +0000 Subject: [PATCH] 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 --- django/db/backends/mysql/base.py | 2 +- django/db/backends/mysql_old/base.py | 2 +- tests/regressiontests/string_lookup/models.py | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) 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')