Code

Ticket #2170: 2170-fix-with-test.diff

File 2170-fix-with-test.diff, 1.7 KB (added by PhiR, 6 years ago)

added a regression test

Line 
1Index: django/db/backends/mysql_old/base.py
2===================================================================
3--- django/db/backends/mysql_old/base.py        (revision 7297)
4+++ django/db/backends/mysql_old/base.py        (working copy)
5@@ -133,7 +133,7 @@
6     features = DatabaseFeatures()
7     ops = DatabaseOperations()
8     operators = {
9-        'exact': '= %s',
10+        'exact': '= BINARY %s',
11         'iexact': 'LIKE %s',
12         'contains': 'LIKE BINARY %s',
13         'icontains': 'LIKE %s',
14Index: django/db/backends/mysql/base.py
15===================================================================
16--- django/db/backends/mysql/base.py    (revision 7297)
17+++ django/db/backends/mysql/base.py    (working copy)
18@@ -128,7 +128,7 @@
19     features = DatabaseFeatures()
20     ops = DatabaseOperations()
21     operators = {
22-        'exact': '= %s',
23+        'exact': '= BINARY %s',
24         'iexact': 'LIKE %s',
25         'contains': 'LIKE BINARY %s',
26         'icontains': 'LIKE %s',
27Index: tests/regressiontests/string_lookup/models.py
28===================================================================
29--- tests/regressiontests/string_lookup/models.py       (revision 7297)
30+++ tests/regressiontests/string_lookup/models.py       (working copy)
31@@ -97,6 +97,12 @@
32 >>> Article.objects.get(text__exact='The quick brown fox jumps over the lazy dog.')
33 <Article: Article Test>
34 
35+# Regression tests for #2170: test case sensitiveness
36+>>> Article.objects.filter(text__exact='tHe qUick bRown fOx jUmps over tHe lazy dog.')
37+[]
38+>>> Article.objects.filter(text__iexact='tHe qUick bRown fOx jUmps over tHe lazy dog.')
39+[<Article: Article Test>]
40+
41 >>> Article.objects.get(text__contains='quick brown fox')
42 <Article: Article Test>
43