Opened 10 years ago

Closed 10 years ago

#22926 closed Bug (wontfix)

order_by parameter in extra method override previous order_by fields

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords: extra, order
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In this example:

qs = qs.extra(select={'f1': 'some_expression'}, order_by=['f1'])
if some_condition:
    qs = qs.extra(select={'f2': 'another_expression'}, order_by=['f2'])

Both f1 and f2 fields are selected but the result is only ordered by f2. I think it is better to append order_by not override it or at least have an option for this.

Change History (1)

comment:1 by Anssi Kääriäinen, 10 years ago

Resolution: wontfix
Status: newclosed

I am going to wontfix this based on following reasons:

  • There are backwards compatibility problems with doing the change
  • .order_by() doesn't work that way either - qs.order_by('f1').order_by('f2') != qs.order_by('f1', 'f2')
Note: See TracTickets for help on using tickets.
Back to Top