Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30501 closed Bug (fixed)

Queryset ordering and Meta.ordering are mutable on expressions with reverse().

Reported by: Mariusz Felisiak Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Queryset order and Meta.ordering are mutable with reverse().

Bug revealed by running ./runtests.py ordering.test --reverse (reproduced at a2c31e12da272acc76f3a3a0157fae9a7f6477ac).

It seems that test added in f218a2ff455b5f7391dd38038994f2c5f8b0eca1 wasn't correct because order mutates on queryset execution in SQLCompiler.get_order_by().

Attachments (1)

30501.diff (2.0 KB ) - added by Mariusz Felisiak 5 years ago.
Tests.

Download all attachments as: .zip

Change History (6)

by Mariusz Felisiak, 5 years ago

Attachment: 30501.diff added

Tests.

comment:1 by Mariusz Felisiak, 5 years ago

Has patch: set

comment:2 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by GitHub <noreply@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In f8b8b00f:

Fixed #30501 -- Preventing QuerySet.reverse() from mutating expressions in QuerySet.order_by and Meta.ordering.

comment:4 by Patryk Zawadzki, 5 years ago

Will this be backported to the 2.2 branch?

comment:5 by Mariusz Felisiak, 5 years ago

I'm sorry, but this doesn't qualify for a backport.

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