File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -482,14 +482,16 @@ Napi::Value Statement::Step(const Napi::CallbackInfo& info) {
482
482
483
483
int r = sqlite3_step (stmt->handle_ );
484
484
485
+ AutoResetStatement auto_reset (stmt, is_get.Value ());
486
+
485
487
// No more rows
486
488
if (r == SQLITE_DONE) {
487
- stmt-> Reset ();
489
+ auto_reset. Reset ();
488
490
return Napi::Value ();
489
491
}
490
492
491
- AutoResetStatement _ (stmt, is_get.Value ());
492
493
if (r != SQLITE_ROW) {
494
+ auto_reset.Reset ();
493
495
return stmt->db_ ->ThrowSqliteError (env, r);
494
496
}
495
497
@@ -498,6 +500,7 @@ Napi::Value Statement::Step(const Napi::CallbackInfo& info) {
498
500
// In pluck mode - return the value of the first column
499
501
if (stmt->is_pluck_ ) {
500
502
if (column_count != 1 ) {
503
+ auto_reset.Reset ();
501
504
NAPI_THROW (Napi::Error::New (env, " Invalid column count for pluck" ),
502
505
Napi::Value ());
503
506
}
@@ -714,6 +717,11 @@ Napi::Value Statement::GetColumnValue(Napi::Env env, int column) {
714
717
return Napi::Value ();
715
718
}
716
719
720
+ void AutoResetStatement::Reset () {
721
+ stmt_->Reset ();
722
+ enabled_ = false ;
723
+ }
724
+
717
725
AutoResetStatement::~AutoResetStatement () {
718
726
if (enabled_) {
719
727
stmt_->Reset ();
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ class AutoResetStatement {
53
53
54
54
~AutoResetStatement ();
55
55
56
+ // Force reset statement now and clear `enabled_`
57
+ void Reset ();
58
+
56
59
private:
57
60
Statement* stmt_;
58
61
bool enabled_;
You can’t perform that action at this time.
0 commit comments