> That sounds like a workable approach. If I'm understanding right, this
means putting the ordering flag on the ExpressionNode class so that all
nodes will have this whether or not they are to be used in an ordering
context?
Yes, that had been what I was thinking, based upon the implementation
In my opinion, Accounts.objects.filter(balance__lt=-F('overdraft_limit'))
would not change the ordering like that. I guess that's an API that doesn't
work at the moment anyway.
An alternative is to use ~ instead of - meaning inverse instead of
negative. This might be more appropriate (but then is
I'm glad it was easy to implement, I was hoping that would be the case. It
also means that expressions are general enough that they can be used
elsewhere in the code base. Thanks for following this through!
> It might be nice (although possibly impractical) to have something like
It might be nice (although possibly impractical) to have something like
order_by(-LowerCase('title')) [using __neg__ on LowerCase]. That might put
logic on the "wrong" objects though. In any case, LowerCase('-title') looks
weird.
Naturally just passing in the string 'title' or '-title' should
I've reworked my approach to ORDER BY to base it on Josh's patch, and it
works very well. It's very straightforward to implement something like this:
Article.objects.order_by(LowerCase('title')) --> ORDER BY
LOWER("some_articles"."title")
This makes use of all the existing expression