I have an instance of django 1.2.1 running on ubuntu with a mysql 5 backend. I am trying to make a case-sensitive query that should only return one result, but I am getting two results back that have the same content but with different cases.
I want to get an entry with the following title: Cat on the Internet syndrome
So I use the following query:
c = Change.objects.filter(change_type='new',title__exact='Cat on the Internet syndrome')
and I get the following results:
>>> c
[<Change: Change object>, <Change: Change object>]
The titles of each Change object:
>>> for i in c:
... print i.title
...
Cat on the Internet Syndrome
Cat on the Internet syndrome
As you can see, the 'S' in syndrome within each object's title has a different case for the S in syndrome. I was under the impression from reading the documentation [0] that all queries default to the 'exact' type. I get the same results when I do not specify title__exact='Cat on the Internet syndrome'
.
How do I ensure that case-sensitivity is used within the query that I outline above?
[0] http://docs.djangoproject.com/en/dev/ref/models/querysets/#std:fieldlookup-exact
Edit: Mysql version is:
mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using readline 6.1
http://code.djangoproject.com/ticket/2170
To get the functionally correctly, change the Collation of the MySql? database to latin1_swedish_cs or utf8_bin for case sensitive comparisons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With