Opened 11 years ago
Closed 11 years ago
#23571 closed Bug (worksforme)
Empty order_by() doesn't work with slice
Description ¶
MyModel.objects.order_by() - use SQL without ORDER BY.
MyModel.objects.order_by()[:10] - use SQL with ORDER BY (default fields for model ordering).
This is a bug or a feature? :)
Change History (2)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
I also cannot reproduce the reported issue:
I added:
class Meta: ordering = ('id',)
to the Poll class in the tutorial.
>>> str(Poll.objects.all().query) 'SELECT "polls_poll"."id", "polls_poll"."question", "polls_poll"."pub_date" FROM "polls_poll" ORDER BY "polls_poll"."id" ASC' >>> str(Poll.objects.order_by().query) 'SELECT "polls_poll"."id", "polls_poll"."question", "polls_poll"."pub_date" FROM "polls_poll"' >>> str(Poll.objects.order_by()[:10].query) 'SELECT "polls_poll"."id", "polls_poll"."question", "polls_poll"."pub_date" FROM "polls_poll" LIMIT 10'
Note:
See TracTickets
for help on using tickets.
Are you sure? How have you checked that ordering is applied? I've checked it in my project and everything works as expected (no ordering in both cases).