prepared statement in ORDER BY not working
Closed this issue · 3 comments
cezaryece commented
I can add query parameter in ORDER BY statement, but seems it not working, means results are not sorted - no error occurs.
dantti commented
what's the query? also this is not related to asql as it doesn't do the sorting, so it's likely a broken query
cezaryece commented
auto query1 = QString("SELECT * FROM anytable ORDER BY %1").arg("id DESC"); - it sorts
auto query2 = QString("SELECT * FROM anytable ORDER BY $1");
auto order = "id DESC but in fact everything is ignored";
ASql::APool::database().exec(query2, {order}, c,..... - it is working (sic! ) but not sorts
dantti commented
first works because the actual query is replaced before sending to the database, the second is not supported by any database as the query planner can't plan without an order by value.