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|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||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"