> SELECT * FROM table WHERE id IN (1, 3, 2) ORDER BY
> FIELD( id, 1, 3, 2 )
I got it to work, but I had to borrow .extra(where=[]), which I
consider a spectacular design failure of the .extra(order_by=[])
system.
Firstly, I TDD using SQLite3, so I had to write code to build either
FIELD( id, 1, 3, 2 ) for MySQL, or (CASE id WHEN 1 THEN 0 WHEN 3 THEN
1 WHEN 2 THEN 2 END) for SQLite3.
Then I attack the query builder like this:
items = items.extra(where=['1=1) ORDER BY (' + order_by_string])
I don't understand why .extra(order_by) has the same "conveniences" as
the .order_by() builder. It insisted on parsing my string instead of
simply appending it.
> --
> Phlip
> http://zeekland.zeroplayer.com/
--
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en.