Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6428 closed (invalid)

database api order_by() doesn't work with dynamic column names if order by descending

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

Description

When the order by column name is passed in as a variable, the API doesn't parse the sorting column name, but take it as a whole, including the "-" sign.
e.g.
sortColumn = "-" + request.GETsortColumn?
print sortColumn #e.g. sortColumn='-type'
myObj = DBObj.objects.all().order_by(sortColumn)

The following SQL is generated, and create an exception
SELECT ... FROM ... ORDER_BY "mytable"."-type"

Change History (2)

comment:1 Changed 7 years ago by JJ <jjdoc@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

comment:2 Changed 7 years ago by JJ <jjdoc@…>

User error

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