From 9aecaff38500fe3458822c54b8fe66488b432033 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 15 Sep 2018 14:47:04 -0600 Subject: [PATCH] bugfix order by (use double quotes, not single) --- lib/dbwrap.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/dbwrap.js b/lib/dbwrap.js index 51d67c9..5175ef9 100644 --- a/lib/dbwrap.js +++ b/lib/dbwrap.js @@ -435,15 +435,18 @@ function wrap(db, dir, dbsMap) { params.orderBy = params.orderByDesc; params.orderByDesc = true; } + + // IMPORTANT: " is not the same to sqlite as '. + // // " is exact and necessary if (params.orderBy) { - sql += " ORDER BY '" + db.escape(snakeCase(params.orderBy)) + "' "; + sql += " ORDER BY \"" + db.escape(snakeCase(params.orderBy)) + "\" "; if (params.orderByDesc) { sql += "DESC "; } } else if (DB._indicesMap.updated_at) { - sql += " ORDER BY 'updated_at' DESC "; + sql += " ORDER BY \"updated_at\" DESC "; } else if (DB._indicesMap.created_at) { - sql += " ORDER BY 'created_at' DESC "; + sql += " ORDER BY \"created_at\" DESC "; } if (isFinite(params.limit)) { sql += " LIMIT " + parseInt(params.limit, 10);