@stoolap/node 0.5.0-beta.1 → 0.5.0-beta.3
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/README.md +1 -1
- package/lib/ffi.js +4 -2
- package/lib/statement.js +7 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -402,7 +402,7 @@ db.querySync(
|
|
|
402
402
|
);
|
|
403
403
|
```
|
|
404
404
|
|
|
405
|
-
Synchronous ad hoc statements pass named parameters to the engine as they are: the SQL is not rewritten, a `:name` inside a string literal is left alone, a name used twice is bound once, keys the SQL does not mention are ignored and a name the object lacks
|
|
405
|
+
Synchronous ad hoc statements pass named parameters to the engine as they are: the SQL is not rewritten, a `:name` inside a string literal is left alone, a name used twice is bound once, keys the SQL does not mention are ignored and a name the object lacks is an error. A prepared statement, and the asynchronous ad hoc methods, resolve `:name` placeholders in the driver and bind by position, which is the engine's fastest path.
|
|
406
406
|
|
|
407
407
|
### Error Handling
|
|
408
408
|
|
package/lib/ffi.js
CHANGED
|
@@ -163,8 +163,10 @@ function processParams(sql, params) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
/* Rewrite :name placeholders to $n for a prepared statement. The engine binds
|
|
166
|
-
* prepared statements faster by position than by name
|
|
167
|
-
*
|
|
166
|
+
* prepared statements faster by position than by name (+10% on a point lookup
|
|
167
|
+
* since the engine's slot binding, +40% before), so a statement keeps its
|
|
168
|
+
* parameter names and binds an object's values positionally. Like the engine,
|
|
169
|
+
* it refuses an object that lacks one of the names. */
|
|
168
170
|
function rewriteNamedParams(sql) {
|
|
169
171
|
const seen = new Map();
|
|
170
172
|
const names = [];
|
package/lib/statement.js
CHANGED
|
@@ -273,7 +273,13 @@ class PreparedStatement {
|
|
|
273
273
|
const names = this.#paramNames;
|
|
274
274
|
if (!names) return null;
|
|
275
275
|
const values = new Array(names.length);
|
|
276
|
-
for (let i = 0; i < names.length; i++)
|
|
276
|
+
for (let i = 0; i < names.length; i++) {
|
|
277
|
+
const name = names[i];
|
|
278
|
+
if (!(name in params)) {
|
|
279
|
+
throw new Error(`invalid argument: named parameter :${name} has no value`);
|
|
280
|
+
}
|
|
281
|
+
values[i] = params[name];
|
|
282
|
+
}
|
|
277
283
|
return values;
|
|
278
284
|
}
|
|
279
285
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoolap/node",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.3",
|
|
4
4
|
"description": "High-performance Node.js driver for Stoolap embedded SQL database",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"bench": "node benchmark.mjs"
|
|
19
19
|
},
|
|
20
20
|
"optionalDependencies": {
|
|
21
|
-
"@stoolap/lib-darwin-arm64": "0.5.0-beta.
|
|
22
|
-
"@stoolap/lib-darwin-x64": "0.5.0-beta.
|
|
23
|
-
"@stoolap/lib-linux-arm64-gnu": "0.5.0-beta.
|
|
24
|
-
"@stoolap/lib-linux-x64-gnu": "0.5.0-beta.
|
|
25
|
-
"@stoolap/lib-win32-x64-msvc": "0.5.0-beta.
|
|
21
|
+
"@stoolap/lib-darwin-arm64": "0.5.0-beta.3",
|
|
22
|
+
"@stoolap/lib-darwin-x64": "0.5.0-beta.3",
|
|
23
|
+
"@stoolap/lib-linux-arm64-gnu": "0.5.0-beta.3",
|
|
24
|
+
"@stoolap/lib-linux-x64-gnu": "0.5.0-beta.3",
|
|
25
|
+
"@stoolap/lib-win32-x64-msvc": "0.5.0-beta.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"better-sqlite3": "^12.6.2",
|