Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#9916 closed (wontfix)

QuerySets should order_by pk as default

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


At least with Postgresql using LIMIT and OFFSET at the same clause will give unpredictable results without an ORDER BY clause. QuerySets should use some kind of ordering as default, so that slicing api would work. At least the documentation at should mention this and the examples without order_by should be removed.

Change History (2)

comment:1 Changed 10 years ago by James Bennett

Resolution: wontfix
Status: newclosed

Forcing ordering when none is specified would be a bad, bad thing. If you want ordering, use order_by() or set the ordering on the model so it'll be applied automatically for you.

comment:2 Changed 10 years ago by Malcolm Tredinnick

The actual problem being reported here will be fixed as part of #9006 and some other ticket I can't find right now. We need some potentially controlled ordering with limit/offset on some database backends. As ubernostrum mentions, though, always ordering is not an option.

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