Opened 17 years ago

Closed 17 years ago

Last modified 17 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

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 by JJ <jjdoc@…>, 17 years ago

Resolution: invalid
Status: newclosed

comment:2 by JJ <jjdoc@…>, 17 years ago

User error

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