Django

Code

Changeset 8319

Show
Ignore:
Timestamp:
08/12/08 02:52:33 (4 months ago)
Author:
mtredinnick
Message:

Changed "exact" matches in MySQL to use the database's native collation.

This effectively reverses the change in [7798]. It was proving too difficult to
successfully manage all the side effects here and provide a satisfactory
solution for everybody. Many thanks to arne, Martin von Löwis and, particular,
Karen Tracey, for doing a lot of research and proto-patches here to establish what was possible and practical.

This is backwards incompatible if you were relying on the behaviour after
[7798]. The docs have been updated to indicate the solution.

Refs #2170, #7789, #8102.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/backends/mysql/base.py

    r8318 r8319  
    154154 
    155155class DatabaseWrapper(BaseDatabaseWrapper): 
    156      
     156 
    157157    operators = { 
    158         'exact': '= BINARY %s', 
     158        'exact': '= %s', 
    159159        'iexact': 'LIKE %s', 
    160160        'contains': 'LIKE BINARY %s', 
  • django/trunk/docs/db-api.txt

    r8291 r8319  
    13281328anything. It has now been changed to behave the same as ``id__isnull=True``. 
    13291329 
     1330.. admonition:: MySQL comparisons 
     1331 
     1332    In MySQL, whether or not ``exact`` comparisons are case-sensitive depends 
     1333    upon the collation setting of the table involved. The default is usually 
     1334    ``latin1_swedish_ci`` or ``utf8_swedish_ci``, which results in 
     1335    case-insensitive comparisons. Change the collation to 
     1336    ``latin1_swedish_cs`` or ``utf8_bin`` for case sensitive comparisons. 
     1337 
     1338    For more details, refer to the MySQL manual section about `character sets 
     1339    and collations`_. 
     1340 
     1341.. _character sets and collations: http://dev.mysql.com/doc/refman/5.0/en/charset.html 
     1342 
    13301343iexact 
    13311344~~~~~~ 
  • django/trunk/tests/regressiontests/string_lookup/models.py

    r7798 r8319  
    9898<Article: Article Test> 
    9999 
    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  
    106100>>> Article.objects.get(text__contains='quick brown fox') 
    107101<Article: Article Test>