Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8154 closed (fixed)

QuerySet.reverse() not working as documented

Reported by: casseen Owned by: nobody
Component: Documentation Version: dev
Severity: Keywords: queryset reverse ordering
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The Documentation suggests that you can call the reverse() function on any queryset.

QuerySet.reverse() is only working if there is specified a default ordering in the model's meta options or the queryset has been ordered with QuerySet.order_by() previously

Change History (5)

comment:1 by Jeff Anderson, 16 years ago

milestone: 1.0
Triage Stage: UnreviewedDesign decision needed

I believe that this is likely a documentation issue. If I recall correctly, without an order_by statement in the actual SQL statement, the database itself isn't necessarily bound to returning anything in any particular order. Reversing something without an order doesn't make sense. Perhaps I'm wrong. Marking DDN.

comment:2 by casseen, 16 years ago

Yes, reverse() should not work on unordered querylist objects. I think it just has to be documented correctly. And it may throw an exception or warning when using on unordered objects.

comment:3 by Malcolm Tredinnick, 16 years ago

Triage Stage: Design decision neededAccepted

The eventual patch here should just say that the results are undetermined if you use it on an unordered queryset. It shouldn't raise an error or a warning so that you can safely call reverse() on something without worrying about whether it's ordered or not. It's harmless to do so, just not particularly useful. So this is a documentation-only issue.

comment:4 by James Bennett, 16 years ago

Resolution: fixed
Status: newclosed

(In [8371]) Fixed #8154: Added note to docs/db-api.txt indicating that reverse() is only useful when the QuerySet has some prior ordering

comment:5 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top