Opened 6 years ago

Closed 6 years ago

Last modified 6 years 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 by Tomer Chachamu, 6 years ago

Has patch: set

comment:2 by Tomer Chachamu, 6 years ago

Owner: Tomer Chachamu removed
Status: assignednew

comment:3 by Tim Graham, 6 years ago

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 by Tomer Chachamu, 6 years ago

Patch needs improvement: unset
Triage Stage: AcceptedUnreviewed

comment:5 by Tomer Chachamu, 6 years ago

Triage Stage: UnreviewedAccepted

comment:6 by Tim Graham <timograham@…>, 6 years ago

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

In 21a3a29d:

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

comment:7 by Tim Graham <timograham@…>, 6 years ago

In 57d46606:

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

Backport of 21a3a29dc9d138c248fd7922923b3ec710735c6c from master

comment:8 by Tim Graham <timograham@…>, 6 years ago

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