#21181: collation specific query results ordering
-------------------------------------+-------------------------------------
Reporter: alan.kesselmann@… | Owner: Alan
Type: New feature | Status: assigned
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ORM | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tom Carrick):
I made a quick attempt at implementing `Collate()` as an expression. I've
hit a problem though, as it seems like SQLIte doesn't allow you to use
parameters with `COLLATE`:
{{{
In [34]: with connection.cursor() as cursor:
...: cursor.execute("select name from testapp_foo order by %s
collate %s", ["name", "nocase"])
...: row = cursor.fetchall()
...
OperationalError: near "?": syntax error
}}}
I also have problems on postgres (haven't tried with other backends):
{{{
In [16]: with connection.cursor() as cursor:
...: cursor.execute("select name from testapp_foo order by %s
collate %s", ["name", "en_US"])
...: row = cursor.fetchone()
...
ProgrammingError: syntax error at or near "'en_US'"
LINE 1: select name from testapp_foo order by 'name' collate 'en_US'
}}}
Not exactly sure what's going on here, but it looks like single quotes
don't do it here. It works if I remove the placeholders and set it with
`"en_US"` - with double quotes.
Maybe I'm misunderstanding something.
--
Ticket URL: <https://code.djangoproject.com/ticket/21181#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/083.a3cb0129e864907278b2aa111e50c8f9%40djangoproject.com.