Abstract the way reverse() works
jonashaag opened this issue · comments
.reverse()
toggles standard_ordering
. Should be abstracted somehow so that backends don't need to care about this attribute. Also related to django-nonrel/mongodb-engine#106
I've implemented a solution on the type-conversion branches -- not the greatest thing to do, but changes to both back-ends were needed and I'd rather not have any more failing tests at the moment :-)
For reference -- here's the (somewhat obsoleted) Django decision on this: https://code.djangoproject.com/ticket/8154.
One may now use QuerySet.reverse
or Manager.reverse
without specifying field ordering (order_by
) to use reverse of the natural database ordering (if a database supports returning results in a reverse order). For example:
Post.objects.filter(title='a').reverse()
or even just:
Post.objects.reverse()
will sort results using $natural: descending
with MongoDB.