#22550: QuerySet last() and reverse() confusing when used with ordered slices
-------------------------------------+-------------------------------------
     Reporter:  jdufresne            |                    Owner:  merll
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  1.6
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:                       |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by merll):

 * has_patch:  0 => 1


Comment:

 A PR has been sent, which fixes the behavior as described in ticket 22550.
 It also includes an addition to the docs, describing that sorting and
 filtering are not possible after the slicing operation:
 https://github.com/django/django/pull/2677

 '''Note:''' It is potentially breaking backwards compatibility in
 `QuerySet.last()` and `QuerySet.reverse()`. Using `reverse()` and `last()`
 on querysets was programmatically possible even after they had been
 sliced, provided that
 * models have defined `ordering`,
 * no further filters or sorting was used.

 Although it has never delivered correct nor consistent results, these two
 functions may have been used under aforementioned conditions. After
 applying this patch, this will raise an error. In this process, the test
 for ticket 7235 had to be revised, as it was relying on the wrong order of
 operations.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22550#comment:3>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.fe5374a1ad72aea35702c5241bb6ff4d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to