Opened 5 weeks ago

Closed 4 weeks ago

Last modified 4 weeks ago

#28722 closed Bug (fixed)

QuerySet.reverse() doesn't reverse nulls_first/nulls_last

Reported by: Tomer Chachamu Owned by: Tim Graham <timograham@…>
Component: Database layer (models, ORM) Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The documentation for Expression.reverse_ordering says it is its own inverse:

https://docs.djangoproject.com/en/1.11/ref/models/expressions/#django.db.models.Expression.reverse_ordering

Returns self with any modifications required to reverse the sort order within an order_by call. As an example, an expression implementing NULLS LAST would change its value to be NULLS FIRST. Modifications are only required for expressions that implement sort order like OrderBy. This method is called when reverse() is called on a queryset.

However, this isn't implemented.
https://github.com/django/django/blob/2b5a511bd9fbd67cedf72b8d39b9522c0140d023/django/db/models/expressions.py#L1133

Change History (8)

comment:1 Changed 5 weeks ago by Tomer Chachamu

Has patch: set

comment:2 Changed 5 weeks ago by Tomer Chachamu

Owner: Tomer Chachamu deleted
Status: assignednew

comment:3 Changed 5 weeks ago by Tim Graham

Patch needs improvement: set
Summary: reverse_ordering does not reverse nulls_first/nulls_lastQuerySet.reverse() doesn't reverse nulls_first/nulls_last
Triage Stage: UnreviewedAccepted

comment:4 Changed 4 weeks ago by Tomer Chachamu

Patch needs improvement: unset
Triage Stage: AcceptedUnreviewed

comment:5 Changed 4 weeks ago by Tomer Chachamu

Triage Stage: UnreviewedAccepted

comment:6 Changed 4 weeks ago by Tim Graham <timograham@…>

Owner: set to Tim Graham <timograham@…>
Resolution: fixed
Status: newclosed

In 21a3a29d:

Fixed #28722 -- Made QuerySet.reverse() affect nulls_first/nulls_last.

comment:7 Changed 4 weeks ago by Tim Graham <timograham@…>

In 57d46606:

[2.0.x] Fixed #28722 -- Made QuerySet.reverse() affect nulls_first/nulls_last.

Backport of 21a3a29dc9d138c248fd7922923b3ec710735c6c from master

comment:8 Changed 4 weeks ago by Tim Graham <timograham@…>

In e98ae4f:

[1.11.x] Fixed #28722 -- Made QuerySet.reverse() affect nulls_first/nulls_last.

Backport of 21a3a29dc9d138c248fd7922923b3ec710735c6c from master

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