@photostructure/sqlite 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,11 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.1.0]
6
+
7
+ ### Changed
8
+
9
+ - **SQLite 3.51.3**: Reverted from 3.52.0 (retracted by the SQLite team)
10
+
5
11
  ## [1.0.0] (2026-03-07)
6
12
 
7
13
  Promotion to v1.0.0 following API stabilization and 0.5.0 release.
8
14
 
9
- API compatible with `node:sqlite` from Node.js v25.8.1.
15
+ API compatible with `node:sqlite` from Node.js v25.8.0.
10
16
 
11
17
  ### Added
12
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@photostructure/sqlite",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Drop-in replacement for node:sqlite",
5
5
  "homepage": "https://photostructure.github.io/node-sqlite/",
6
6
  "types": "./dist/index.d.ts",
@@ -141,7 +141,7 @@
141
141
  "eslint": "^9.39.2",
142
142
  "eslint-plugin-regexp": "^3.0.0",
143
143
  "eslint-plugin-security": "^4.0.0",
144
- "globals": "^17.3.0",
144
+ "globals": "^17.4.0",
145
145
  "jest": "^30.2.0",
146
146
  "node-gyp": "^12.2.0",
147
147
  "npm-check-updates": "^19.6.3",
@@ -157,7 +157,7 @@
157
157
  "typescript-eslint": "^8.56.1"
158
158
  },
159
159
  "versions": {
160
- "nodejs": "v25.8.1@f91cf7f",
160
+ "nodejs": "v25.x-staging@ca2d6ea",
161
161
  "sqlite": "3.52.0"
162
162
  }
163
163
  }
@@ -2421,6 +2421,11 @@ inline bool StatementSync::IsFinalized() {
2421
2421
  return statement_ == nullptr;
2422
2422
  }
2423
2423
 
2424
+ inline int StatementSync::ResetStatement() {
2425
+ reset_generation_++;
2426
+ return sqlite3_reset(statement_);
2427
+ }
2428
+
2424
2429
  bool StatementSync::BindParams(const FunctionCallbackInfo<Value>& args) {
2425
2430
  int r = sqlite3_clear_bindings(statement_);
2426
2431
  CHECK_ERROR_OR_THROW(env()->isolate(), db_.get(), r, SQLITE_OK, false);
@@ -2812,7 +2817,7 @@ void StatementSync::All(const FunctionCallbackInfo<Value>& args) {
2812
2817
  THROW_AND_RETURN_ON_BAD_STATE(
2813
2818
  env, stmt->IsFinalized(), "statement has been finalized");
2814
2819
  Isolate* isolate = env->isolate();
2815
- int r = sqlite3_reset(stmt->statement_);
2820
+ int r = stmt->ResetStatement();
2816
2821
  CHECK_ERROR_OR_THROW(isolate, stmt->db_.get(), r, SQLITE_OK, void());
2817
2822
 
2818
2823
  if (!stmt->BindParams(args)) {
@@ -2838,7 +2843,7 @@ void StatementSync::Iterate(const FunctionCallbackInfo<Value>& args) {
2838
2843
  Environment* env = Environment::GetCurrent(args);
2839
2844
  THROW_AND_RETURN_ON_BAD_STATE(
2840
2845
  env, stmt->IsFinalized(), "statement has been finalized");
2841
- int r = sqlite3_reset(stmt->statement_);
2846
+ int r = stmt->ResetStatement();
2842
2847
  CHECK_ERROR_OR_THROW(env->isolate(), stmt->db_.get(), r, SQLITE_OK, void());
2843
2848
 
2844
2849
  if (!stmt->BindParams(args)) {
@@ -2861,7 +2866,7 @@ void StatementSync::Get(const FunctionCallbackInfo<Value>& args) {
2861
2866
  Environment* env = Environment::GetCurrent(args);
2862
2867
  THROW_AND_RETURN_ON_BAD_STATE(
2863
2868
  env, stmt->IsFinalized(), "statement has been finalized");
2864
- int r = sqlite3_reset(stmt->statement_);
2869
+ int r = stmt->ResetStatement();
2865
2870
  CHECK_ERROR_OR_THROW(env->isolate(), stmt->db_.get(), r, SQLITE_OK, void());
2866
2871
 
2867
2872
  if (!stmt->BindParams(args)) {
@@ -2885,7 +2890,7 @@ void StatementSync::Run(const FunctionCallbackInfo<Value>& args) {
2885
2890
  Environment* env = Environment::GetCurrent(args);
2886
2891
  THROW_AND_RETURN_ON_BAD_STATE(
2887
2892
  env, stmt->IsFinalized(), "statement has been finalized");
2888
- int r = sqlite3_reset(stmt->statement_);
2893
+ int r = stmt->ResetStatement();
2889
2894
  CHECK_ERROR_OR_THROW(env->isolate(), stmt->db_.get(), r, SQLITE_OK, void());
2890
2895
 
2891
2896
  if (!stmt->BindParams(args)) {
@@ -3430,6 +3435,7 @@ StatementSyncIterator::StatementSyncIterator(Environment* env,
3430
3435
  : BaseObject(env, object), stmt_(std::move(stmt)) {
3431
3436
  MakeWeak();
3432
3437
  done_ = false;
3438
+ statement_reset_generation_ = stmt_->reset_generation_;
3433
3439
  }
3434
3440
 
3435
3441
  StatementSyncIterator::~StatementSyncIterator() {}
@@ -3444,7 +3450,7 @@ Local<FunctionTemplate> StatementSyncIterator::GetConstructorTemplate(
3444
3450
  tmpl = NewFunctionTemplate(isolate, IllegalConstructor);
3445
3451
  tmpl->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "StatementSyncIterator"));
3446
3452
  tmpl->InstanceTemplate()->SetInternalFieldCount(
3447
- StatementSync::kInternalFieldCount);
3453
+ StatementSyncIterator::kInternalFieldCount);
3448
3454
  SetProtoMethod(isolate, tmpl, "next", StatementSyncIterator::Next);
3449
3455
  SetProtoMethod(isolate, tmpl, "return", StatementSyncIterator::Return);
3450
3456
  env->set_sqlite_statement_sync_iterator_constructor_template(tmpl);
@@ -3488,6 +3494,11 @@ void StatementSyncIterator::Next(const FunctionCallbackInfo<Value>& args) {
3488
3494
  return;
3489
3495
  }
3490
3496
 
3497
+ THROW_AND_RETURN_ON_BAD_STATE(
3498
+ env,
3499
+ iter->statement_reset_generation_ != iter->stmt_->reset_generation_,
3500
+ "iterator was invalidated");
3501
+
3491
3502
  int r = sqlite3_step(iter->stmt_->statement_);
3492
3503
  if (r != SQLITE_ROW) {
3493
3504
  CHECK_ERROR_OR_THROW(
@@ -291,7 +291,9 @@ class StatementSync : public BaseObject {
291
291
  bool use_big_ints_;
292
292
  bool allow_bare_named_params_;
293
293
  bool allow_unknown_named_params_;
294
+ uint64_t reset_generation_ = 0;
294
295
  std::optional<std::map<std::string, std::string>> bare_named_params_;
296
+ inline int ResetStatement();
295
297
  bool BindParams(const v8::FunctionCallbackInfo<v8::Value>& args);
296
298
  bool BindValue(const v8::Local<v8::Value>& value, const int index);
297
299
 
@@ -321,6 +323,7 @@ class StatementSyncIterator : public BaseObject {
321
323
  ~StatementSyncIterator() override;
322
324
  BaseObjectPtr<StatementSync> stmt_;
323
325
  bool done_;
326
+ uint64_t statement_reset_generation_;
324
327
  };
325
328
 
326
329
  using Sqlite3ChangesetGenFunc = int (*)(sqlite3_session*, int*, void**);