You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a stmt instance by db.prepare, then I found the 'get' method of stmt cannot return correct result but undefined after the first time it was called when there is no parameter for this method.
I think this bug is caused by the if condition here:
if (stmt->status != SQLITE_DONE || baton->parameters.size()) {
Steps to Reproduce
constsqlite3=require('sqlite3');functionpromiseify(fn){returnfunction(...args){returnnewPromise((resolve,reject)=>{fn(...args,(err,res)=>{if(err){reject(err);}else{resolve(res);}});});};}constdb=newsqlite3.Database(':memory:');(async()=>{//no parameter testconststmt=awaitdb.prepare('select 1');//simply select 1 hereconstget=promiseify((cb)=>{returnstmt.get(cb);});console.log(awaitget());//print { '1': 1 }console.log(awaitget());//print undefinedconsole.log(awaitget());//print undefined//You can see the `get` method won't return a result from the second call.//1 parameter testconststmt2=awaitdb.prepare('select 1+?');constget2=promiseify((arg,cb)=>{returnstmt2.get(arg,cb);});console.log(awaitget2(1));//print { '1+?': 2 }console.log(awaitget2(2));//print { '1+?': 3 }console.log(awaitget2(3));//print { '1+?': 4 }//it returns correctly when there have parameter})();
Version
5.1.6
Node.js Version
v18.17.0
How did you install the library?
npm i, on windows
The text was updated successfully, but these errors were encountered:
JiaJiaJiang
changed the title
A used stmt can not get result when there is no parameter
A used stmt can not get result by get() when there is no parameter
Jan 1, 2024
Issue Summary
I created a stmt instance by
db.prepare
, then I found the 'get' method of stmt cannot return correct result butundefined
after the first time it was called when there is no parameter for this method.I think this bug is caused by the if condition here:
node-sqlite3/src/statement.cc
Line 406 in 03d6e75
Steps to Reproduce
Version
5.1.6
Node.js Version
v18.17.0
How did you install the library?
npm i, on windows
The text was updated successfully, but these errors were encountered: