bugfix order by (use double quotes, not single)

This commit is contained in:
AJ ONeal 2018-09-15 14:47:04 -06:00
parent cfd516e24f
commit 9aecaff385
1 changed files with 6 additions and 3 deletions

View File

@ -435,15 +435,18 @@ function wrap(db, dir, dbsMap) {
params.orderBy = params.orderByDesc; params.orderBy = params.orderByDesc;
params.orderByDesc = true; params.orderByDesc = true;
} }
// IMPORTANT: " is not the same to sqlite as '.
// // " is exact and necessary
if (params.orderBy) { if (params.orderBy) {
sql += " ORDER BY '" + db.escape(snakeCase(params.orderBy)) + "' "; sql += " ORDER BY \"" + db.escape(snakeCase(params.orderBy)) + "\" ";
if (params.orderByDesc) { if (params.orderByDesc) {
sql += "DESC "; sql += "DESC ";
} }
} else if (DB._indicesMap.updated_at) { } else if (DB._indicesMap.updated_at) {
sql += " ORDER BY 'updated_at' DESC "; sql += " ORDER BY \"updated_at\" DESC ";
} else if (DB._indicesMap.created_at) { } else if (DB._indicesMap.created_at) {
sql += " ORDER BY 'created_at' DESC "; sql += " ORDER BY \"created_at\" DESC ";
} }
if (isFinite(params.limit)) { if (isFinite(params.limit)) {
sql += " LIMIT " + parseInt(params.limit, 10); sql += " LIMIT " + parseInt(params.limit, 10);