Author: mtredinnick
Date: 2011-08-26 01:42:38 -0700 (Fri, 26 Aug 2011)
New Revision: 16694

Modified:
   django/trunk/docs/ref/databases.txt
   django/trunk/docs/ref/models/querysets.txt
Log:
Clarify the documentation around SQLite and case-sensitive string matching.

This was still causing some confusion, so I rewrote the section in the
database notes to encompass both substring matching and non-ASCII
case-insensitive equality checks, as well as putting in a stronger
callout on the "contains" filter.

Refs #16569.

Modified: django/trunk/docs/ref/databases.txt
===================================================================
--- django/trunk/docs/ref/databases.txt 2011-08-26 08:18:05 UTC (rev 16693)
+++ django/trunk/docs/ref/databases.txt 2011-08-26 08:42:38 UTC (rev 16694)
@@ -380,15 +380,28 @@
 
 .. _sqlite-string-matching:
 
-String matching for non-ASCII strings
---------------------------------------
+Substring matching and case sensitivity
+-----------------------------------------
 
-SQLite doesn't support case-insensitive matching for non-ASCII strings. Some
-possible workarounds for this are `documented at sqlite.org`_, but they are
-not utilised by the default SQLite backend in Django. Therefore, if you are
-using the ``iexact`` lookup type in your queryset filters, be aware that it
-will not work as expected for non-ASCII strings.
+For all SQLite versions, there is some slightly counter-intuitive behavior when
+attempting to match some types of strings.  These are triggered when using the
+:lookup:`iexact` or :lookup:`contains` filters in Querysets. The behavior
+splits into two cases:
 
+1. For substring matching, all matches are done case-insensitively. That is a
+filter such as ``filter(name__contains="aa")`` will match a name of ``"Aabb"``.
+
+2. For strings containing characters outside the ASCII range, all exact string
+matches are performed case-sensitively, even when the case-insensitive options
+are passed into the query. So the :lookup:`iexact` filter will behave exactly
+the same as the :lookup:`exact` filter in these cases.
+
+Some possible workarounds for this are `documented at sqlite.org`_, but they
+aren't utilised by the default SQLite backend in Django, as incorporating them
+would be fairly difficult to do robustly. Thus, Django exposes the default
+SQLite behavior and you should be aware of this when doing case-insensitive or
+substring filtering.
+
 .. _documented at sqlite.org: http://www.sqlite.org/faq.html#q18
 
 SQLite 3.3.6 or newer strongly recommended

Modified: django/trunk/docs/ref/models/querysets.txt
===================================================================
--- django/trunk/docs/ref/models/querysets.txt  2011-08-26 08:18:05 UTC (rev 
16693)
+++ django/trunk/docs/ref/models/querysets.txt  2011-08-26 08:42:38 UTC (rev 
16694)
@@ -1476,9 +1476,13 @@
 Note this will match the headline ``'Today Lennon honored'`` but not
 ``'today lennon honored'``.
 
-SQLite doesn't support case-sensitive ``LIKE`` statements; ``contains`` acts
-like ``icontains`` for SQLite.
+.. admonition:: SQLite users
 
+    SQLite doesn't support case-sensitive ``LIKE`` statements; ``contains``
+    acts like ``icontains`` for SQLite. See the :ref:`database note
+    <sqlite-string-matching>` for more information.
+
+
 .. fieldlookup:: icontains
 
 icontains

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to