@sqb/sqlite 6.1.1 → 6.2.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/constants.d.ts +1 -1
- package/constants.js +1 -1
- package/package.json +4 -4
- package/sqlite-connection.js +16 -1
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/sqlite",
|
|
3
3
|
"description": "SQB adapter for Node.js and Bun's native SQLite drivers",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.2.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"homepage": "https://www.sqbjs.org",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"tslib": "^2.8.1"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@sqb/builder": "^6.
|
|
13
|
-
"@sqb/connect": "^6.
|
|
14
|
-
"@sqb/sqlite-dialect": "^6.
|
|
12
|
+
"@sqb/builder": "^6.2.0",
|
|
13
|
+
"@sqb/connect": "^6.2.0",
|
|
14
|
+
"@sqb/sqlite-dialect": "^6.2.0"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"module": "./index.js",
|
package/sqlite-connection.js
CHANGED
|
@@ -113,7 +113,7 @@ export class SqliteConnection {
|
|
|
113
113
|
const m2 = query.sql.match(/where (.+)/i);
|
|
114
114
|
sql += m2 ? ' where ' + m2[1] : '';
|
|
115
115
|
const selStmt = intlcon.prepare(sql);
|
|
116
|
-
this._fillSelectResult(out, selStmt, selStmt.all(params), query);
|
|
116
|
+
this._fillSelectResult(out, selStmt, selStmt.all(pickParams(sql, params)), query);
|
|
117
117
|
return out;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -182,6 +182,21 @@ function mapParams(params) {
|
|
|
182
182
|
out[':' + k] = params[k];
|
|
183
183
|
return out;
|
|
184
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Keeps only the (already `:`-prefixed) params that `sql` references:
|
|
187
|
+
* `node:sqlite` throws on a named parameter the statement doesn't have, and
|
|
188
|
+
* the `SET` values of an `UPDATE` are not part of its re-`SELECT`.
|
|
189
|
+
*/
|
|
190
|
+
function pickParams(sql, params) {
|
|
191
|
+
if (!params)
|
|
192
|
+
return params;
|
|
193
|
+
const used = new Set(sql.match(/:[\w$]+/g));
|
|
194
|
+
const out = {};
|
|
195
|
+
for (const k of Object.keys(params))
|
|
196
|
+
if (used.has(k))
|
|
197
|
+
out[k] = params[k];
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
185
200
|
/**
|
|
186
201
|
* Maps a SQLite declared column type to a {dataType, jsType} pair using
|
|
187
202
|
* SQLite's type affinity rules (https://www.sqlite.org/datatype3.html).
|