Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24060 closed New feature (fixed)

Allow expressions to be used in order_by queryset method

Reported by: Josh Smeaton Owned by: Josh Smeaton
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: expressions order_by 1.8-alpha
Cc: josh.smeaton@… 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

Now that expressions have landed, we should try to expand the scope of queryset methods where they are allowed as arguments. There is a proof of concept for allowing order_by to accept expressions here: https://groups.google.com/forum/#!topic/django-developers/arR7B_Luszc

I'm marking this as 1.8, as I plan to clean up the patch and have it ready before the alpha. If it doesn't make it in time, we can change the version.

Change History (8)

comment:1 by Josh Smeaton, 9 years ago

Cc: josh.smeaton@… added
Owner: set to Josh Smeaton
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

comment:2 by Anssi Kääriäinen, 9 years ago

One case to be aware: QuerySet.reverse(). This should work for any custom expression order_by, too. This means that if .order_by(NullsLast('somecol')) produces SQL like:

   SELECT ... FROM ... ORDER BY somecol ASC NULLS LAST

then .order_by(NullsLast('somecol')).reverse() should produce SQL like:

   SELECT ... FROM ... ORDER BY somecol DESC NULLS FIRST

comment:3 by Josh Smeaton, 9 years ago

Has patch: set
Needs documentation: set
Needs tests: set
Patch needs improvement: set

comment:4 by Tim Graham, 9 years ago

Keywords: 1.8-alpha added

comment:5 by Josh Smeaton, 9 years ago

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:6 by Josh Smeaton <josh.smeaton@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 21b858cb6735cdfdc695ff7b076e4cbc1981bc88:

Fixed #24060 -- Added OrderBy Expressions

comment:7 by Josh Smeaton <josh.smeaton@…>, 9 years ago

In f218a2ff455b5f7391dd38038994f2c5f8b0eca1:

Refs #24060 -- Added a test demonstrating reverse order isn't mutable

comment:8 by Josh Smeaton <josh.smeaton@…>, 9 years ago

In 405351ba2f639a1a0c092ecb6d93f9f7a646686a:

[1.8.x] Refs #24060 -- Added a test demonstrating reverse order isn't mutable

Backport of f218a2ff455b5f7391dd38038994f2c5f8b0eca1 from master

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