From e726c24a83dc468004a3bfb499647052ba194967 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 2 Jan 2016 21:24:17 -0800 Subject: [PATCH] bugfix: convert value to string --- lib/dbwrap.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/dbwrap.js b/lib/dbwrap.js index 0de66f3..0ab2959 100644 --- a/lib/dbwrap.js +++ b/lib/dbwrap.js @@ -10,7 +10,7 @@ function wrap(db, dir) { var debug = false; db.escape = function (str) { - return (str||'').replace(/'/g, "''"); + return (str||'').toString().replace(/'/g, "''"); }; function lowerFirst(str) { @@ -42,7 +42,7 @@ function wrap(db, dir) { } // PRAGMA schema.table_info(table-name); - // + // function sqlite3GetColumns(tablename, columns, cb) { var sql = "PRAGMA table_info(" + db.escape(tablename) + ")"; @@ -421,6 +421,12 @@ function wrap(db, dir) { sql = cb(fieldable); + if (debug) { + console.log('[masterquest-sqlite3] dbwrap.js'); + console.log(sql); + console.log(vals); + } + while (vals.length) { sql = sql.replace(/\?/, "'" + db.escape(vals.shift()) + "'"); }