jayralencar / sqlite-sync.js

Node module to sqlite sync and async
MIT License
78 stars 30 forks source link

? substitution broken for strings using "?" character #14

Closed roninski closed 6 years ago

roninski commented 6 years ago

Repro: sqlite.run('CREATE TABLE IF NOT EXISTS things(id INTEGER PRIMARY KEY, word STR, things INT)'); sqlite.run("INSERT INTO things(id, word, things) VALUES (?, ?, ?)",[1, "???", 10]);

Expected: "INSERT INTO things(id, word, things) VALUES (1, '???', 10)" Actual: "INSERT INTO things(id, word, things) VALUES (1, '10??', ?)"

Seems to be an issue due to the prevalance of this loop (e.g. sqlite.js line 233): if(data){ for(var i = 0 ; i < data.length; i++){ sql = sql.replace('?',"'"+data[i]+"'"); } }

jayralencar commented 6 years ago

Hi @roninski, I will test it.

jayralencar commented 6 years ago

Fixed here Try installing 0.3.7