#11283: latest() doesn't clear previous ordering
------------------------------------------+---------------------------------
Reporter: benmoran | Owner: nobody
Status: new | Milestone:
Component: Database layer (models, ORM) | Version: 1.0
Keywords: | Stage: Unreviewed
Has_patch: 1 |
------------------------------------------+---------------------------------
Unlike order_by() in django.db.models.query, the latest() method doesn't
clear previous orderings.
This means that latest can return incorrect results if used on a
previously sorted QuerySet, e.g.
{{{ Article.objects.order_by('id').latest('id') }}}
returns the first rather than the last id.
It looks strange when written on a single line, but can happen - I
encountered it with code from django-reversion using QuerySets that
already had orderings set.
--
Ticket URL: <http://code.djangoproject.com/ticket/11283>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---