Opened 11 years ago

Closed 11 years ago

Last modified 11 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: no UI/UX: no


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.
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 11 years ago by JJ <jjdoc@…>

Resolution: invalid
Status: newclosed

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

User error

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