I am missing order by nulls [first|last]
Either I am blind, or it is not possible.
Do other miss this, too?
Thomas
--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
> I am missing order by nulls [first|last]
>
> Either I am blind, or it is not possible.
I think this is database-dependent.
--
We read Knuth so you don't have to. - Tim Peters
Jarek Zgoda, R&D, Redefine
jarek...@redefine.pl
something like this:
MyModel.objects.all().order_by('due_date', nulls_last=True)
I don't know if all database backends support this. Postgres does.
I'm not really in a great hurry to implement anything like this. Django
supplies a reasonable layer over SQL, but doesn't intend to cover every
single case and this is on the edge. One could also argue that if you're
routinely sorting by columns that contain NULLs and you rely on the
NULLs being first or last, you're probably not following "best
practices" at some level (and, yes, I fully realise there are
counter-arguments as well). But I think we can manage to go on living
without this type of option.
By design, QuerySets and Query are subclassable. If you really need this
support, add an extra call to your QuerySet subclass that incorporates
that into the extension of Query.as_sql() and use that QuerySet subclass
as the one returned by your custom manager.
Regards,
Malcolm