Commit 9d23fd43 authored by Jarosław Staniek's avatar Jarosław Staniek
Browse files

Fix crash for SELECT queries containing "ORDER BY 0"

0 is an invalid sorting index and this fact should be reported to the
user. Example query: "SELECT foo FROM table ORDER BY 0".
parent 71d5f1b6
......@@ -554,7 +554,7 @@ void OrderByColumnList::appendColumn(QueryColumnInfo& columnInfo, bool ascending
bool OrderByColumnList::appendColumn(QuerySchema& querySchema, bool ascending, int pos)
QueryColumnInfo::Vector fieldsExpanded(querySchema.fieldsExpanded());
QueryColumnInfo* ci = (pos >= (int)fieldsExpanded.size()) ? 0 : fieldsExpanded[pos];
QueryColumnInfo* ci = (pos < 0 || pos >= (int)fieldsExpanded.size()) ? 0 : fieldsExpanded[pos];
if (!ci)
return false;
append(new OrderByColumn(*ci, ascending, pos));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment