better-sqlite3-multiple-ciphers 7.4.7-beta.0 → 7.5.1-beta.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.
Files changed (81) hide show
  1. package/README.md +8 -6
  2. package/deps/download.sh +111 -108
  3. package/deps/setup.ps1 +10 -12
  4. package/deps/sqlite3/sqlite3.c +272560 -0
  5. package/deps/sqlite3/sqlite3.h +12770 -0
  6. package/deps/sqlite3/sqlite3ext.h +675 -0
  7. package/deps/sqlite3.gyp +17 -7
  8. package/deps/symlink.js +7 -4
  9. package/lib/database.js +17 -6
  10. package/lib/sqlite-error.js +1 -2
  11. package/package.json +11 -5
  12. package/src/better_sqlite3.cpp +46 -35
  13. package/src/better_sqlite3.hpp +40 -38
  14. package/.gitattributes +0 -1
  15. package/.github/workflows/prebuild.yml +0 -49
  16. package/.github/workflows/test.yml +0 -59
  17. package/benchmark/benchmark.js +0 -31
  18. package/benchmark/drivers.js +0 -21
  19. package/benchmark/index.js +0 -83
  20. package/benchmark/seed.js +0 -47
  21. package/benchmark/trials.js +0 -65
  22. package/benchmark/types/insert.js +0 -16
  23. package/benchmark/types/select-all.js +0 -14
  24. package/benchmark/types/select-iterate.js +0 -23
  25. package/benchmark/types/select.js +0 -14
  26. package/benchmark/types/transaction.js +0 -40
  27. package/deps/extract.js +0 -16
  28. package/deps/sqlite3.tar.gz +0 -0
  29. package/docs/api.md +0 -645
  30. package/docs/benchmark.md +0 -38
  31. package/docs/compilation.md +0 -76
  32. package/docs/integer.md +0 -79
  33. package/docs/performance.md +0 -39
  34. package/docs/threads.md +0 -97
  35. package/docs/tips.md +0 -35
  36. package/docs/troubleshooting.md +0 -23
  37. package/docs/unsafe.md +0 -16
  38. package/src/better_sqlite3.lzz +0 -88
  39. package/src/objects/backup.lzz +0 -138
  40. package/src/objects/database.lzz +0 -468
  41. package/src/objects/statement-iterator.lzz +0 -138
  42. package/src/objects/statement.lzz +0 -323
  43. package/src/util/bind-map.lzz +0 -73
  44. package/src/util/binder.lzz +0 -190
  45. package/src/util/constants.lzz +0 -151
  46. package/src/util/custom-aggregate.lzz +0 -121
  47. package/src/util/custom-function.lzz +0 -59
  48. package/src/util/custom-table.lzz +0 -397
  49. package/src/util/data-converter.lzz +0 -17
  50. package/src/util/data.lzz +0 -145
  51. package/src/util/macros.lzz +0 -159
  52. package/src/util/query-macros.lzz +0 -71
  53. package/test/00.setup.js +0 -25
  54. package/test/01.sqlite-error.js +0 -27
  55. package/test/10.database.open.js +0 -159
  56. package/test/11.database.close.js +0 -68
  57. package/test/12.database.pragma.js +0 -65
  58. package/test/13.database.prepare.js +0 -60
  59. package/test/14.database.exec.js +0 -46
  60. package/test/20.statement.run.js +0 -170
  61. package/test/21.statement.get.js +0 -109
  62. package/test/22.statement.all.js +0 -129
  63. package/test/23.statement.iterate.js +0 -223
  64. package/test/24.statement.bind.js +0 -107
  65. package/test/25.statement.columns.js +0 -46
  66. package/test/30.database.transaction.js +0 -157
  67. package/test/31.database.checkpoint.js +0 -62
  68. package/test/32.database.function.js +0 -211
  69. package/test/33.database.aggregate.js +0 -603
  70. package/test/34.database.table.js +0 -671
  71. package/test/35.database.load-extension.js +0 -75
  72. package/test/36.database.backup.js +0 -240
  73. package/test/37.database.serialize.js +0 -81
  74. package/test/40.bigints.js +0 -145
  75. package/test/41.at-exit.js +0 -52
  76. package/test/42.integrity.js +0 -531
  77. package/test/43.verbose.js +0 -100
  78. package/test/44.worker-threads.js +0 -66
  79. package/test/45.unsafe-mode.js +0 -52
  80. package/test/46.encryption.js +0 -69
  81. package/test/50.misc.js +0 -44
package/deps/sqlite3.gyp CHANGED
@@ -1,7 +1,6 @@
1
1
  # ===
2
2
  # This configuration defines options specific to compiling SQLite3 itself.
3
3
  # Compile-time options are loaded by the auto-generated file "defines.gypi".
4
- # Before SQLite3 is compiled, it gets extracted from "sqlite3.tar.gz".
5
4
  # The --sqlite3 option can be provided to use a custom amalgamation instead.
6
5
  # ===
7
6
 
@@ -15,24 +14,31 @@
15
14
  'conditions': [
16
15
  ['sqlite3 == ""', {
17
16
  'actions': [{
18
- 'action_name': 'extract_sqlite3',
19
- 'inputs': ['sqlite3.tar.gz'],
17
+ 'action_name': 'symlink_builtin_sqlite3',
18
+ 'inputs': [
19
+ 'sqlite3/sqlite3.c',
20
+ 'sqlite3/sqlite3.h',
21
+ 'sqlite3/sqlite3ext.h',
22
+ ],
20
23
  'outputs': [
21
24
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
22
25
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
23
26
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3ext.h',
24
27
  ],
25
- 'action': ['node', 'extract.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3'],
28
+ 'action': ['node', 'symlink.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '', 'sqlite3.c', 'sqlite3.h', 'sqlite3ext.h'],
26
29
  }],
27
30
  }, {
28
31
  'actions': [{
29
- 'action_name': 'symlink_sqlite3',
30
- 'inputs': [],
32
+ 'action_name': 'symlink_custom_sqlite3',
33
+ 'inputs': [
34
+ '<(sqlite3)/sqlite3.c',
35
+ '<(sqlite3)/sqlite3.h',
36
+ ],
31
37
  'outputs': [
32
38
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
33
39
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
34
40
  ],
35
- 'action': ['node', 'symlink.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '<(sqlite3)'],
41
+ 'action': ['node', 'symlink.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '<(sqlite3)', 'sqlite3.c', 'sqlite3.h'],
36
42
  }],
37
43
  }],
38
44
  ],
@@ -67,6 +73,10 @@
67
73
  'cflags!': ['-maes', '-msse4.2'],
68
74
  'cflags': ['-march=native'],
69
75
  }],
76
+ ['target_arch=="arm"', {
77
+ 'cflags!': ['-maes', '-msse4.2'],
78
+ 'cflags': ['-march=native'],
79
+ }],
70
80
  ],
71
81
  'configurations': {
72
82
  'Debug': {
package/deps/symlink.js CHANGED
@@ -3,14 +3,17 @@ const path = require('path');
3
3
  const fs = require('fs');
4
4
 
5
5
  const dest = process.argv[2];
6
- const source = path.resolve(path.sep, process.argv[3]);
6
+ const source = path.resolve(path.sep, process.argv[3] || path.join(__dirname, 'sqlite3'));
7
+ const filenames = process.argv.slice(4).map(str => path.basename(str));
7
8
 
8
9
  /*
9
- This creates symlinks inside the <$2> directory, linking to the SQLite3
10
- amalgamation files inside the directory specified by the absolute path <$3>.
10
+ This creates symlinks inside the <$2> directory, linking to files inside the
11
+ directory specified by the absolute path <$3>. If no path <$3> is provided,
12
+ the default path of "./deps/sqlite3" is used. The basenames of the files to
13
+ link are specified by <$4...>.
11
14
  */
12
15
 
13
- for (const filename of ['sqlite3.c', 'sqlite3.h']) {
16
+ for (const filename of filenames) {
14
17
  fs.accessSync(path.join(source, filename));
15
18
  fs.symlinkSync(path.join(source, filename), path.join(dest, filename), 'file');
16
19
  }
package/lib/database.js CHANGED
@@ -2,11 +2,9 @@
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
  const util = require('./util');
5
+ const SqliteError = require('./sqlite-error');
5
6
 
6
- const {
7
- Database: CPPDatabase,
8
- setErrorConstructor,
9
- } = require('bindings')('better_sqlite3.node');
7
+ let DEFAULT_ADDON;
10
8
 
11
9
  function Database(filenameGiven, options) {
12
10
  if (new.target == null) {
@@ -35,12 +33,26 @@ function Database(filenameGiven, options) {
35
33
  const fileMustExist = util.getBooleanOption(options, 'fileMustExist');
36
34
  const timeout = 'timeout' in options ? options.timeout : 5000;
37
35
  const verbose = 'verbose' in options ? options.verbose : null;
36
+ const nativeBindingPath = 'nativeBinding' in options ? options.nativeBinding : null;
38
37
 
39
38
  // Validate interpreted options
40
39
  if (readonly && anonymous && !buffer) throw new TypeError('In-memory/temporary databases cannot be readonly');
41
40
  if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
42
41
  if (timeout > 0x7fffffff) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
43
42
  if (verbose != null && typeof verbose !== 'function') throw new TypeError('Expected the "verbose" option to be a function');
43
+ if (nativeBindingPath != null && typeof nativeBindingPath !== 'string') throw new TypeError('Expected the "nativeBinding" option to be a string');
44
+
45
+ // Load the native addon
46
+ let addon;
47
+ if (nativeBindingPath == null) {
48
+ addon = DEFAULT_ADDON || (DEFAULT_ADDON = require('bindings')('better_sqlite3.node'));
49
+ } else {
50
+ addon = require(path.resolve(nativeBindingPath).replace(/(\.node)?$/, '.node'));
51
+ }
52
+ if (!addon.isInitialized) {
53
+ addon.setErrorConstructor(SqliteError);
54
+ addon.isInitialized = true;
55
+ }
44
56
 
45
57
  // Make sure the specified directory exists
46
58
  if (!anonymous && !fs.existsSync(path.dirname(filename))) {
@@ -48,7 +60,7 @@ function Database(filenameGiven, options) {
48
60
  }
49
61
 
50
62
  Object.defineProperties(this, {
51
- [util.cppdb]: { value: new CPPDatabase(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
63
+ [util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
52
64
  ...wrappers.getters,
53
65
  });
54
66
  }
@@ -70,4 +82,3 @@ Database.prototype.unsafeMode = wrappers.unsafeMode;
70
82
  Database.prototype[util.inspect] = require('./methods/inspect');
71
83
 
72
84
  module.exports = Database;
73
- setErrorConstructor(require('./sqlite-error'));
@@ -12,8 +12,7 @@ function SqliteError(message, code) {
12
12
  descriptor.value = '' + message;
13
13
  Object.defineProperty(this, 'message', descriptor);
14
14
  Error.captureStackTrace(this, SqliteError);
15
- descriptor.value = code;
16
- Object.defineProperty(this, 'code', descriptor);
15
+ this.code = code;
17
16
  }
18
17
  Object.setPrototypeOf(SqliteError, Error);
19
18
  Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
package/package.json CHANGED
@@ -1,18 +1,23 @@
1
1
  {
2
2
  "name": "better-sqlite3-multiple-ciphers",
3
- "version": "7.4.7-beta.0",
3
+ "version": "7.5.1-beta.0",
4
4
  "description": "better-sqlite3 with multiple-cipher encryption support",
5
5
  "homepage": "https://github.com/m4heshd/better-sqlite3-multiple-ciphers",
6
6
  "author": "Mahesh Bandara Wijerathna (m4heshd) <m4heshd@gmail.com>",
7
- "main": "lib/index.js",
8
7
  "repository": {
9
8
  "type": "git",
10
9
  "url": "git://github.com/m4heshd/better-sqlite3-multiple-ciphers.git"
11
10
  },
11
+ "main": "lib/index.js",
12
+ "files": [
13
+ "binding.gyp",
14
+ "src/*.[ch]pp",
15
+ "lib/**",
16
+ "deps/**"
17
+ ],
12
18
  "dependencies": {
13
19
  "bindings": "^1.5.0",
14
- "prebuild-install": "^7.0.0",
15
- "tar": "^6.1.11"
20
+ "prebuild-install": "^7.0.0"
16
21
  },
17
22
  "devDependencies": {
18
23
  "chai": "^4.3.4",
@@ -30,7 +35,7 @@
30
35
  "build-debug": "node-gyp rebuild --debug",
31
36
  "rebuild-release": "npm run lzz && npm run build-release",
32
37
  "rebuild-debug": "npm run lzz && npm run build-debug",
33
- "test": "mocha --exit --slow=75 --timeout=5000",
38
+ "test": "mocha --exit --slow=75 --timeout=30000",
34
39
  "benchmark": "node benchmark",
35
40
  "download": "bash ./deps/download.sh",
36
41
  "setup": "powershell ./deps/setup.ps1",
@@ -52,6 +57,7 @@
52
57
  "sqlite3",
53
58
  "sqleet",
54
59
  "sqlcipher",
60
+ "sqlite3multipleciphers",
55
61
  "encryption",
56
62
  "transactions",
57
63
  "user-defined functions",
@@ -759,11 +759,12 @@ v8::Local <v8 :: Function> Statement::Init (v8::Isolate * isolate, v8::Local <v8
759
759
  SetPrototypeMethod(isolate, data, t, "raw", JS_raw);
760
760
  SetPrototypeMethod(isolate, data, t, "safeIntegers", JS_safeIntegers);
761
761
  SetPrototypeMethod(isolate, data, t, "columns", JS_columns);
762
+ SetPrototypeGetter(isolate, data, t, "busy", JS_busy);
762
763
  return t->GetFunction( isolate -> GetCurrentContext ( ) ).ToLocalChecked();
763
764
  }
764
- #line 25 "./src/objects/statement.lzz"
765
+ #line 26 "./src/objects/statement.lzz"
765
766
  BindMap * Statement::GetBindMap (v8::Isolate * isolate)
766
- #line 25 "./src/objects/statement.lzz"
767
+ #line 26 "./src/objects/statement.lzz"
767
768
  {
768
769
  if (has_bind_map) return &extras->bind_map;
769
770
  BindMap* bind_map = &extras->bind_map;
@@ -775,34 +776,34 @@ BindMap * Statement::GetBindMap (v8::Isolate * isolate)
775
776
  has_bind_map = true;
776
777
  return bind_map;
777
778
  }
778
- #line 38 "./src/objects/statement.lzz"
779
+ #line 39 "./src/objects/statement.lzz"
779
780
  void Statement::CloseHandles ()
780
- #line 38 "./src/objects/statement.lzz"
781
+ #line 39 "./src/objects/statement.lzz"
781
782
  {
782
783
  if (alive) {
783
784
  alive = false;
784
785
  sqlite3_finalize(handle);
785
786
  }
786
787
  }
787
- #line 45 "./src/objects/statement.lzz"
788
+ #line 46 "./src/objects/statement.lzz"
788
789
  Statement::~ Statement ()
789
- #line 45 "./src/objects/statement.lzz"
790
+ #line 46 "./src/objects/statement.lzz"
790
791
  {
791
792
  if (alive) db->RemoveStatement(this);
792
793
  CloseHandles();
793
794
  delete extras;
794
795
  }
795
- #line 55 "./src/objects/statement.lzz"
796
+ #line 56 "./src/objects/statement.lzz"
796
797
  Statement::Extras::Extras (sqlite3_uint64 id)
797
- #line 55 "./src/objects/statement.lzz"
798
+ #line 56 "./src/objects/statement.lzz"
798
799
  : bind_map (0), id (id)
799
- #line 55 "./src/objects/statement.lzz"
800
+ #line 56 "./src/objects/statement.lzz"
800
801
  {}
801
- #line 60 "./src/objects/statement.lzz"
802
+ #line 61 "./src/objects/statement.lzz"
802
803
  Statement::Statement (Database * db, sqlite3_stmt * handle, sqlite3_uint64 id, bool returns_data)
803
- #line 65 "./src/objects/statement.lzz"
804
+ #line 66 "./src/objects/statement.lzz"
804
805
  : node::ObjectWrap (), db (db), handle (handle), extras (new Extras(id)), alive (true), locked (false), bound (false), has_bind_map (false), safe_ints (db->GetState()->safe_ints), mode (Data::FLAT), returns_data (returns_data)
805
- #line 76 "./src/objects/statement.lzz"
806
+ #line 77 "./src/objects/statement.lzz"
806
807
  {
807
808
  assert(db != NULL);
808
809
  assert(handle != NULL);
@@ -810,9 +811,9 @@ Statement::Statement (Database * db, sqlite3_stmt * handle, sqlite3_uint64 id, b
810
811
  assert(!db->GetState()->busy);
811
812
  db->AddStatement(this);
812
813
  }
813
- #line 84 "./src/objects/statement.lzz"
814
+ #line 85 "./src/objects/statement.lzz"
814
815
  void Statement::JS_new (v8::FunctionCallbackInfo <v8 :: Value> const & info)
815
- #line 84 "./src/objects/statement.lzz"
816
+ #line 85 "./src/objects/statement.lzz"
816
817
  {
817
818
  Addon * addon = static_cast < Addon * > ( info . Data ( ) . As < v8 :: External > ( ) -> Value ( ) ) ;
818
819
  if (!addon->privileged_info) {
@@ -876,11 +877,11 @@ void Statement::JS_new (v8::FunctionCallbackInfo <v8 :: Value> const & info)
876
877
 
877
878
  info.GetReturnValue().Set(info.This());
878
879
  }
879
- #line 148 "./src/objects/statement.lzz"
880
+ #line 149 "./src/objects/statement.lzz"
880
881
  void Statement::JS_run (v8::FunctionCallbackInfo <v8 :: Value> const & info)
881
- #line 148 "./src/objects/statement.lzz"
882
+ #line 149 "./src/objects/statement.lzz"
882
883
  {
883
- Statement * stmt = node :: ObjectWrap :: Unwrap < Statement > ( info . This ( ) ) ; ( ( void ) 0 ) ; sqlite3_stmt * handle = stmt -> handle ; Database * db = stmt -> db ; if ( ! db -> GetState ( ) -> open ) return ThrowTypeError ( "The database connection is not open" ) ; if ( db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; assert ( ! stmt -> locked ) ; if ( ! db -> GetState ( ) -> unsafe_mode ) { if ( db -> GetState ( ) -> iterators ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; } ( ( void ) 0 ) ; const bool bound = stmt -> bound ; if ( ! bound ) { Binder binder ( handle ) ; if ( ! binder . Bind ( info , info . Length ( ) , stmt ) ) { sqlite3_clear_bindings ( handle ) ; return ; } ( ( void ) 0 ) ; } else if ( info . Length ( ) > 0 ) { return ThrowTypeError ( "This statement already has bound parameters" ) ; } ( ( void ) 0 ) ; db -> GetState ( ) -> busy = true ; v8 :: Isolate * isolate = info . GetIsolate ( ) ; if ( db -> Log ( isolate , handle ) ) { db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ; } ( ( void ) 0 ) ;
884
+ Statement * stmt = node :: ObjectWrap :: Unwrap < Statement > ( info . This ( ) ) ; ( ( void ) 0 ) ; sqlite3_stmt * handle = stmt -> handle ; Database * db = stmt -> db ; if ( ! db -> GetState ( ) -> open ) return ThrowTypeError ( "The database connection is not open" ) ; if ( db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; if ( stmt -> locked ) return ThrowTypeError ( "This statement is busy executing a query" ) ; if ( ! db -> GetState ( ) -> unsafe_mode ) { if ( db -> GetState ( ) -> iterators ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; } ( ( void ) 0 ) ; const bool bound = stmt -> bound ; if ( ! bound ) { Binder binder ( handle ) ; if ( ! binder . Bind ( info , info . Length ( ) , stmt ) ) { sqlite3_clear_bindings ( handle ) ; return ; } ( ( void ) 0 ) ; } else if ( info . Length ( ) > 0 ) { return ThrowTypeError ( "This statement already has bound parameters" ) ; } ( ( void ) 0 ) ; db -> GetState ( ) -> busy = true ; v8 :: Isolate * isolate = info . GetIsolate ( ) ; if ( db -> Log ( isolate , handle ) ) { db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ; } ( ( void ) 0 ) ;
884
885
  sqlite3* db_handle = db->GetHandle();
885
886
  int total_changes_before = sqlite3_total_changes(db_handle);
886
887
 
@@ -901,9 +902,9 @@ void Statement::JS_run (v8::FunctionCallbackInfo <v8 :: Value> const & info)
901
902
  }
902
903
  db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ;
903
904
  }
904
- #line 171 "./src/objects/statement.lzz"
905
+ #line 172 "./src/objects/statement.lzz"
905
906
  void Statement::JS_get (v8::FunctionCallbackInfo <v8 :: Value> const & info)
906
- #line 171 "./src/objects/statement.lzz"
907
+ #line 172 "./src/objects/statement.lzz"
907
908
  {
908
909
  Statement * stmt = node :: ObjectWrap :: Unwrap < Statement > ( info . This ( ) ) ; if ( ! stmt -> returns_data ) return ThrowTypeError ( "This statement does not return data. Use run() instead" ) ; sqlite3_stmt * handle = stmt -> handle ; Database * db = stmt -> db ; if ( ! db -> GetState ( ) -> open ) return ThrowTypeError ( "The database connection is not open" ) ; if ( db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; if ( stmt -> locked ) return ThrowTypeError ( "This statement is busy executing a query" ) ; const bool bound = stmt -> bound ; if ( ! bound ) { Binder binder ( handle ) ; if ( ! binder . Bind ( info , info . Length ( ) , stmt ) ) { sqlite3_clear_bindings ( handle ) ; return ; } ( ( void ) 0 ) ; } else if ( info . Length ( ) > 0 ) { return ThrowTypeError ( "This statement already has bound parameters" ) ; } ( ( void ) 0 ) ; db -> GetState ( ) -> busy = true ; v8 :: Isolate * isolate = info . GetIsolate ( ) ; if ( db -> Log ( isolate , handle ) ) { db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ; } ( ( void ) 0 ) ;
909
910
  int status = sqlite3_step(handle);
@@ -918,9 +919,9 @@ void Statement::JS_get (v8::FunctionCallbackInfo <v8 :: Value> const & info)
918
919
  sqlite3_reset(handle);
919
920
  db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ;
920
921
  }
921
- #line 186 "./src/objects/statement.lzz"
922
+ #line 187 "./src/objects/statement.lzz"
922
923
  void Statement::JS_all (v8::FunctionCallbackInfo <v8 :: Value> const & info)
923
- #line 186 "./src/objects/statement.lzz"
924
+ #line 187 "./src/objects/statement.lzz"
924
925
  {
925
926
  Statement * stmt = node :: ObjectWrap :: Unwrap < Statement > ( info . This ( ) ) ; if ( ! stmt -> returns_data ) return ThrowTypeError ( "This statement does not return data. Use run() instead" ) ; sqlite3_stmt * handle = stmt -> handle ; Database * db = stmt -> db ; if ( ! db -> GetState ( ) -> open ) return ThrowTypeError ( "The database connection is not open" ) ; if ( db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; if ( stmt -> locked ) return ThrowTypeError ( "This statement is busy executing a query" ) ; const bool bound = stmt -> bound ; if ( ! bound ) { Binder binder ( handle ) ; if ( ! binder . Bind ( info , info . Length ( ) , stmt ) ) { sqlite3_clear_bindings ( handle ) ; return ; } ( ( void ) 0 ) ; } else if ( info . Length ( ) > 0 ) { return ThrowTypeError ( "This statement already has bound parameters" ) ; } ( ( void ) 0 ) ; db -> GetState ( ) -> busy = true ; v8 :: Isolate * isolate = info . GetIsolate ( ) ; if ( db -> Log ( isolate , handle ) ) { db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ; } ( ( void ) 0 ) ;
926
927
  v8 :: Local < v8 :: Context > ctx = isolate -> GetCurrentContext ( ) ;
@@ -941,9 +942,9 @@ void Statement::JS_all (v8::FunctionCallbackInfo <v8 :: Value> const & info)
941
942
  if (js_error) db->GetState()->was_js_error = true;
942
943
  db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ;
943
944
  }
944
- #line 207 "./src/objects/statement.lzz"
945
+ #line 208 "./src/objects/statement.lzz"
945
946
  void Statement::JS_iterate (v8::FunctionCallbackInfo <v8 :: Value> const & info)
946
- #line 207 "./src/objects/statement.lzz"
947
+ #line 208 "./src/objects/statement.lzz"
947
948
  {
948
949
  Addon * addon = static_cast < Addon * > ( info . Data ( ) . As < v8 :: External > ( ) -> Value ( ) ) ;
949
950
  v8 :: Isolate * isolate = info . GetIsolate ( ) ;
@@ -953,9 +954,9 @@ void Statement::JS_iterate (v8::FunctionCallbackInfo <v8 :: Value> const & info)
953
954
  addon->privileged_info = NULL;
954
955
  if (!maybeIterator.IsEmpty()) info.GetReturnValue().Set(maybeIterator.ToLocalChecked());
955
956
  }
956
- #line 217 "./src/objects/statement.lzz"
957
+ #line 218 "./src/objects/statement.lzz"
957
958
  void Statement::JS_bind (v8::FunctionCallbackInfo <v8 :: Value> const & info)
958
- #line 217 "./src/objects/statement.lzz"
959
+ #line 218 "./src/objects/statement.lzz"
959
960
  {
960
961
  Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
961
962
  if (stmt->bound) return ThrowTypeError("The bind() method can only be invoked once per statement object");
@@ -966,9 +967,9 @@ void Statement::JS_bind (v8::FunctionCallbackInfo <v8 :: Value> const & info)
966
967
  stmt->bound = true;
967
968
  info.GetReturnValue().Set(info.This());
968
969
  }
969
- #line 228 "./src/objects/statement.lzz"
970
+ #line 229 "./src/objects/statement.lzz"
970
971
  void Statement::JS_pluck (v8::FunctionCallbackInfo <v8 :: Value> const & info)
971
- #line 228 "./src/objects/statement.lzz"
972
+ #line 229 "./src/objects/statement.lzz"
972
973
  {
973
974
  Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
974
975
  if (!stmt->returns_data) return ThrowTypeError("The pluck() method is only for statements that return data");
@@ -979,9 +980,9 @@ void Statement::JS_pluck (v8::FunctionCallbackInfo <v8 :: Value> const & info)
979
980
  stmt->mode = use ? Data::PLUCK : stmt->mode == Data::PLUCK ? Data::FLAT : stmt->mode;
980
981
  info.GetReturnValue().Set(info.This());
981
982
  }
982
- #line 239 "./src/objects/statement.lzz"
983
+ #line 240 "./src/objects/statement.lzz"
983
984
  void Statement::JS_expand (v8::FunctionCallbackInfo <v8 :: Value> const & info)
984
- #line 239 "./src/objects/statement.lzz"
985
+ #line 240 "./src/objects/statement.lzz"
985
986
  {
986
987
  Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
987
988
  if (!stmt->returns_data) return ThrowTypeError("The expand() method is only for statements that return data");
@@ -992,9 +993,9 @@ void Statement::JS_expand (v8::FunctionCallbackInfo <v8 :: Value> const & info)
992
993
  stmt->mode = use ? Data::EXPAND : stmt->mode == Data::EXPAND ? Data::FLAT : stmt->mode;
993
994
  info.GetReturnValue().Set(info.This());
994
995
  }
995
- #line 250 "./src/objects/statement.lzz"
996
+ #line 251 "./src/objects/statement.lzz"
996
997
  void Statement::JS_raw (v8::FunctionCallbackInfo <v8 :: Value> const & info)
997
- #line 250 "./src/objects/statement.lzz"
998
+ #line 251 "./src/objects/statement.lzz"
998
999
  {
999
1000
  Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
1000
1001
  if (!stmt->returns_data) return ThrowTypeError("The raw() method is only for statements that return data");
@@ -1005,9 +1006,9 @@ void Statement::JS_raw (v8::FunctionCallbackInfo <v8 :: Value> const & info)
1005
1006
  stmt->mode = use ? Data::RAW : stmt->mode == Data::RAW ? Data::FLAT : stmt->mode;
1006
1007
  info.GetReturnValue().Set(info.This());
1007
1008
  }
1008
- #line 261 "./src/objects/statement.lzz"
1009
+ #line 262 "./src/objects/statement.lzz"
1009
1010
  void Statement::JS_safeIntegers (v8::FunctionCallbackInfo <v8 :: Value> const & info)
1010
- #line 261 "./src/objects/statement.lzz"
1011
+ #line 262 "./src/objects/statement.lzz"
1011
1012
  {
1012
1013
  Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
1013
1014
  if ( stmt -> db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ;
@@ -1016,9 +1017,9 @@ void Statement::JS_safeIntegers (v8::FunctionCallbackInfo <v8 :: Value> const &
1016
1017
  else { if ( info . Length ( ) <= ( 0 ) || ! info [ 0 ] -> IsBoolean ( ) ) return ThrowTypeError ( "Expected " "first" " argument to be " "a boolean" ) ; stmt -> safe_ints = ( info [ 0 ] . As < v8 :: Boolean > ( ) ) -> Value ( ) ; }
1017
1018
  info.GetReturnValue().Set(info.This());
1018
1019
  }
1019
- #line 270 "./src/objects/statement.lzz"
1020
+ #line 271 "./src/objects/statement.lzz"
1020
1021
  void Statement::JS_columns (v8::FunctionCallbackInfo <v8 :: Value> const & info)
1021
- #line 270 "./src/objects/statement.lzz"
1022
+ #line 271 "./src/objects/statement.lzz"
1022
1023
  {
1023
1024
  Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
1024
1025
  if (!stmt->returns_data) return ThrowTypeError("The columns() method is only for statements that return data");
@@ -1061,6 +1062,13 @@ void Statement::JS_columns (v8::FunctionCallbackInfo <v8 :: Value> const & info)
1061
1062
 
1062
1063
  info.GetReturnValue().Set(columns);
1063
1064
  }
1065
+ #line 314 "./src/objects/statement.lzz"
1066
+ void Statement::JS_busy (v8::Local <v8 :: String> _, v8::PropertyCallbackInfo <v8 :: Value> const & info)
1067
+ #line 314 "./src/objects/statement.lzz"
1068
+ {
1069
+ Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
1070
+ info.GetReturnValue().Set(stmt->alive && stmt->locked);
1071
+ }
1064
1072
  #line 4 "./src/objects/statement-iterator.lzz"
1065
1073
  v8::Local <v8 :: Function> StatementIterator::Init (v8::Isolate * isolate, v8::Local <v8 :: External> data)
1066
1074
  #line 4 "./src/objects/statement-iterator.lzz"
@@ -2077,6 +2085,9 @@ Binder::Result Binder::BindArgs (v8::FunctionCallbackInfo <v8 :: Value> const &
2077
2085
  count += BindObject(isolate, obj, stmt);
2078
2086
  if (!success) break;
2079
2087
  continue;
2088
+ } else if (stmt->GetBindMap(isolate)->GetSize()) {
2089
+ Fail(ThrowTypeError, "Named parameters can only be passed within plain objects");
2090
+ break;
2080
2091
  }
2081
2092
  }
2082
2093
 
@@ -312,71 +312,73 @@ class Statement : public node::ObjectWrap
312
312
  public:
313
313
  #line 4 "./src/objects/statement.lzz"
314
314
  static v8::Local <v8 :: Function> Init (v8::Isolate * isolate, v8::Local <v8 :: External> data);
315
- #line 20 "./src/objects/statement.lzz"
315
+ #line 21 "./src/objects/statement.lzz"
316
316
  static bool Compare (Statement const * const a, Statement const * const b);
317
- #line 25 "./src/objects/statement.lzz"
317
+ #line 26 "./src/objects/statement.lzz"
318
318
  BindMap * GetBindMap (v8::Isolate * isolate);
319
- #line 38 "./src/objects/statement.lzz"
319
+ #line 39 "./src/objects/statement.lzz"
320
320
  void CloseHandles ();
321
- #line 45 "./src/objects/statement.lzz"
321
+ #line 46 "./src/objects/statement.lzz"
322
322
  ~ Statement ();
323
- #line 51 "./src/objects/statement.lzz"
323
+ #line 52 "./src/objects/statement.lzz"
324
324
  private:
325
- #line 54 "./src/objects/statement.lzz"
325
+ #line 55 "./src/objects/statement.lzz"
326
326
  class Extras
327
327
  {
328
- #line 54 "./src/objects/statement.lzz"
329
- friend class Statement;
330
328
  #line 55 "./src/objects/statement.lzz"
331
- explicit Extras (sqlite3_uint64 id);
329
+ friend class Statement;
332
330
  #line 56 "./src/objects/statement.lzz"
333
- BindMap bind_map;
331
+ explicit Extras (sqlite3_uint64 id);
334
332
  #line 57 "./src/objects/statement.lzz"
333
+ BindMap bind_map;
334
+ #line 58 "./src/objects/statement.lzz"
335
335
  sqlite3_uint64 const id;
336
336
  };
337
- #line 60 "./src/objects/statement.lzz"
337
+ #line 61 "./src/objects/statement.lzz"
338
338
  explicit Statement (Database * db, sqlite3_stmt * handle, sqlite3_uint64 id, bool returns_data);
339
- #line 84 "./src/objects/statement.lzz"
339
+ #line 85 "./src/objects/statement.lzz"
340
340
  static void JS_new (v8::FunctionCallbackInfo <v8 :: Value> const & info);
341
- #line 148 "./src/objects/statement.lzz"
341
+ #line 149 "./src/objects/statement.lzz"
342
342
  static void JS_run (v8::FunctionCallbackInfo <v8 :: Value> const & info);
343
- #line 171 "./src/objects/statement.lzz"
343
+ #line 172 "./src/objects/statement.lzz"
344
344
  static void JS_get (v8::FunctionCallbackInfo <v8 :: Value> const & info);
345
- #line 186 "./src/objects/statement.lzz"
345
+ #line 187 "./src/objects/statement.lzz"
346
346
  static void JS_all (v8::FunctionCallbackInfo <v8 :: Value> const & info);
347
- #line 207 "./src/objects/statement.lzz"
347
+ #line 208 "./src/objects/statement.lzz"
348
348
  static void JS_iterate (v8::FunctionCallbackInfo <v8 :: Value> const & info);
349
- #line 217 "./src/objects/statement.lzz"
349
+ #line 218 "./src/objects/statement.lzz"
350
350
  static void JS_bind (v8::FunctionCallbackInfo <v8 :: Value> const & info);
351
- #line 228 "./src/objects/statement.lzz"
351
+ #line 229 "./src/objects/statement.lzz"
352
352
  static void JS_pluck (v8::FunctionCallbackInfo <v8 :: Value> const & info);
353
- #line 239 "./src/objects/statement.lzz"
353
+ #line 240 "./src/objects/statement.lzz"
354
354
  static void JS_expand (v8::FunctionCallbackInfo <v8 :: Value> const & info);
355
- #line 250 "./src/objects/statement.lzz"
355
+ #line 251 "./src/objects/statement.lzz"
356
356
  static void JS_raw (v8::FunctionCallbackInfo <v8 :: Value> const & info);
357
- #line 261 "./src/objects/statement.lzz"
357
+ #line 262 "./src/objects/statement.lzz"
358
358
  static void JS_safeIntegers (v8::FunctionCallbackInfo <v8 :: Value> const & info);
359
- #line 270 "./src/objects/statement.lzz"
359
+ #line 271 "./src/objects/statement.lzz"
360
360
  static void JS_columns (v8::FunctionCallbackInfo <v8 :: Value> const & info);
361
- #line 313 "./src/objects/statement.lzz"
362
- Database * const db;
363
361
  #line 314 "./src/objects/statement.lzz"
362
+ static void JS_busy (v8::Local <v8 :: String> _, v8::PropertyCallbackInfo <v8 :: Value> const & info);
363
+ #line 319 "./src/objects/statement.lzz"
364
+ Database * const db;
365
+ #line 320 "./src/objects/statement.lzz"
364
366
  sqlite3_stmt * const handle;
365
- #line 315 "./src/objects/statement.lzz"
367
+ #line 321 "./src/objects/statement.lzz"
366
368
  Extras * const extras;
367
- #line 316 "./src/objects/statement.lzz"
369
+ #line 322 "./src/objects/statement.lzz"
368
370
  bool alive;
369
- #line 317 "./src/objects/statement.lzz"
371
+ #line 323 "./src/objects/statement.lzz"
370
372
  bool locked;
371
- #line 318 "./src/objects/statement.lzz"
373
+ #line 324 "./src/objects/statement.lzz"
372
374
  bool bound;
373
- #line 319 "./src/objects/statement.lzz"
375
+ #line 325 "./src/objects/statement.lzz"
374
376
  bool has_bind_map;
375
- #line 320 "./src/objects/statement.lzz"
377
+ #line 326 "./src/objects/statement.lzz"
376
378
  bool safe_ints;
377
- #line 321 "./src/objects/statement.lzz"
379
+ #line 327 "./src/objects/statement.lzz"
378
380
  char mode;
379
- #line 322 "./src/objects/statement.lzz"
381
+ #line 328 "./src/objects/statement.lzz"
380
382
  bool const returns_data;
381
383
  };
382
384
  #line 1 "./src/objects/statement-iterator.lzz"
@@ -764,13 +766,13 @@ private:
764
766
  int BindObject (v8::Isolate * isolate, v8::Local <v8::Object> obj, Statement * stmt);
765
767
  #line 149 "./src/util/binder.lzz"
766
768
  Result BindArgs (v8::FunctionCallbackInfo <v8 :: Value> const & info, int argc, Statement * stmt);
767
- #line 186 "./src/util/binder.lzz"
769
+ #line 189 "./src/util/binder.lzz"
768
770
  sqlite3_stmt * handle;
769
- #line 187 "./src/util/binder.lzz"
771
+ #line 190 "./src/util/binder.lzz"
770
772
  int param_count;
771
- #line 188 "./src/util/binder.lzz"
773
+ #line 191 "./src/util/binder.lzz"
772
774
  int anon_index;
773
- #line 189 "./src/util/binder.lzz"
775
+ #line 192 "./src/util/binder.lzz"
774
776
  bool success;
775
777
  };
776
778
  #line 34 "./src/better_sqlite3.lzz"
@@ -916,9 +918,9 @@ LZZ_INLINE Addon * Database::GetAddon ()
916
918
  {
917
919
  return addon;
918
920
  }
919
- #line 20 "./src/objects/statement.lzz"
921
+ #line 21 "./src/objects/statement.lzz"
920
922
  LZZ_INLINE bool Statement::Compare (Statement const * const a, Statement const * const b)
921
- #line 20 "./src/objects/statement.lzz"
923
+ #line 21 "./src/objects/statement.lzz"
922
924
  {
923
925
  return a->extras->id < b->extras->id;
924
926
  }
package/.gitattributes DELETED
@@ -1 +0,0 @@
1
- *.lzz linguist-language=C++
@@ -1,49 +0,0 @@
1
- name: prebuild
2
-
3
- on:
4
- release:
5
- types:
6
- - published
7
-
8
- jobs:
9
- prebuild:
10
- strategy:
11
- matrix:
12
- os:
13
- - ubuntu-18.04
14
- - macos-latest
15
- - windows-latest
16
- name: Prebuild on ${{ matrix.os }}
17
- runs-on: ${{ matrix.os }}
18
- steps:
19
- - uses: actions/checkout@v2
20
- - uses: actions/setup-node@v2
21
- with:
22
- node-version: 16
23
- - run: npm install --ignore-scripts
24
- - run: npx --no-install prebuild -r node -t 10.20.0 -t 12.0.0 -t 14.0.0 -t 16.0.0 --include-regex 'better_sqlite3.node$' -u ${{ secrets.GITHUB_TOKEN }}
25
- - run: npx --no-install prebuild -r electron -t 10.0.0 -t 11.0.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 15.0.0 -t 16.0.0 --include-regex 'better_sqlite3.node$' -u ${{ secrets.GITHUB_TOKEN }}
26
- - if: matrix.os == 'windows-latest'
27
- run: npx --no-install prebuild -r electron -t 10.0.0 -t 11.0.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 15.0.0 -t 16.0.0 --include-regex 'better_sqlite3.node$' --arch ia32 -u ${{ secrets.GITHUB_TOKEN }}
28
-
29
- prebuild-alpine:
30
- name: Prebuild on alpine
31
- runs-on: ubuntu-latest
32
- container: node:16-alpine
33
- steps:
34
- - uses: actions/checkout@v2
35
- - run: apk add build-base git python3 --update-cache
36
- - run: npm install --ignore-scripts
37
- - run: npx --no-install prebuild -r node -t 10.20.0 -t 12.0.0 -t 14.0.0 -t 16.0.0 --include-regex 'better_sqlite3.node$' -u ${{ secrets.GITHUB_TOKEN }}
38
-
39
- prebuild-alpine-arm64:
40
- name: Prebuild on alpine (arm64)
41
- runs-on: ubuntu-latest
42
- steps:
43
- - uses: docker/setup-qemu-action@v1
44
- - run: |
45
- docker run --rm --entrypoint /bin/sh --platform linux/arm64 node:16-alpine -c "apk add build-base git python3 --update-cache && \
46
- git clone ${{ github.event.repository.clone_url }} && \
47
- cd ${{ github.event.repository.name }} && \
48
- npm install --ignore-scripts && \
49
- npx --no-install prebuild -r node -t 10.20.0 -t 12.0.0 -t 14.0.0 -t 16.0.0 --include-regex 'better_sqlite3.node$' -u ${{ secrets.GITHUB_TOKEN }}"