#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 , 18 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
comment:2 by , 18 years ago
Note:
See TracTickets
for help on using tickets.
User error