@unvired/cordova-plugin-unvired-electron-db 0.0.42 → 0.0.43
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/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/browser/DbPluginProxy.js +24 -31
- package/src/electron/package.json +1 -1
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
id="@unvired/cordova-plugin-unvired-electron-db"
|
|
4
|
-
version="0.0.
|
|
4
|
+
version="0.0.43"
|
|
5
5
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
6
6
|
<name>Unvired DB</name>
|
|
7
7
|
<description>Unvired DB Native Support for Cordova</description>
|
|
@@ -30,32 +30,25 @@ module.exports.execute = async function (sucessCallback, errorCallback, options)
|
|
|
30
30
|
try {
|
|
31
31
|
const db = dbType == DBType.FrameworkDb ? webDb.fwDb : webDb.appDb;
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
while (stmt.step()) {
|
|
41
|
-
var row = stmt.getAsObject();
|
|
42
|
-
rows.push(row);
|
|
43
|
-
}
|
|
44
|
-
stmt.free();
|
|
45
|
-
sucessCallback(rows);
|
|
33
|
+
// Parse query and convert to prepared statement with bound values for ALL query types
|
|
34
|
+
const parsedQuery = webDb.parseQueryToPrepared(query);
|
|
35
|
+
let stmt;
|
|
36
|
+
|
|
37
|
+
if (parsedQuery.values.length > 0) {
|
|
38
|
+
stmt = db.prepare(parsedQuery.query);
|
|
39
|
+
stmt.bind(parsedQuery.values);
|
|
46
40
|
} else {
|
|
47
|
-
|
|
48
|
-
const parsedQuery = webDb.parseQueryToPrepared(query);
|
|
49
|
-
if (parsedQuery.isPrepared) {
|
|
50
|
-
var stmt = db.prepare(parsedQuery.query);
|
|
51
|
-
stmt.run(parsedQuery.values);
|
|
52
|
-
stmt.free();
|
|
53
|
-
} else {
|
|
54
|
-
// Fallback to exec for queries without parameters
|
|
55
|
-
db.exec(query);
|
|
56
|
-
}
|
|
57
|
-
sucessCallback("Success");
|
|
41
|
+
stmt = db.prepare(query);
|
|
58
42
|
}
|
|
43
|
+
|
|
44
|
+
// Execute statement and capture results if any
|
|
45
|
+
let rows = [];
|
|
46
|
+
while (stmt.step()) {
|
|
47
|
+
rows.push(stmt.getAsObject());
|
|
48
|
+
}
|
|
49
|
+
stmt.free();
|
|
50
|
+
|
|
51
|
+
sucessCallback(rows);
|
|
59
52
|
}
|
|
60
53
|
catch (err) {
|
|
61
54
|
console.error("Error executing query: " + query, err);
|
|
@@ -252,7 +245,7 @@ var webDb = /** @class */ (function () {
|
|
|
252
245
|
|
|
253
246
|
// If query already contains positional placeholders, don't attempt to re-parameterize it.
|
|
254
247
|
if (query.indexOf('?') !== -1) {
|
|
255
|
-
return {
|
|
248
|
+
return { query: query, values: [] };
|
|
256
249
|
}
|
|
257
250
|
if (queryUpper.startsWith('CREATE') ||
|
|
258
251
|
queryUpper.startsWith('DROP') ||
|
|
@@ -276,7 +269,7 @@ var webDb = /** @class */ (function () {
|
|
|
276
269
|
// DDL/transactional statements and similar should not be parameterized.
|
|
277
270
|
// Note: INSERT ... VALUES will be parameterized below so large
|
|
278
271
|
// string/numeric literals (eg. base64 blobs) can be bound safely.
|
|
279
|
-
return {
|
|
272
|
+
return { query: query, values: [] };
|
|
280
273
|
}
|
|
281
274
|
|
|
282
275
|
|
|
@@ -285,7 +278,7 @@ var webDb = /** @class */ (function () {
|
|
|
285
278
|
const hasNumericLiterals = /\b\d+\.?\d*\b/.test(query);
|
|
286
279
|
|
|
287
280
|
if (!hasStringLiterals && !hasNumericLiterals) {
|
|
288
|
-
return {
|
|
281
|
+
return { query: query, values: [] };
|
|
289
282
|
}
|
|
290
283
|
|
|
291
284
|
// We'll scan the original query left-to-right and replace literals with
|
|
@@ -333,7 +326,7 @@ var webDb = /** @class */ (function () {
|
|
|
333
326
|
|
|
334
327
|
if (!closed) {
|
|
335
328
|
// Unmatched quote; bail out to safe fallback to avoid errors
|
|
336
|
-
return {
|
|
329
|
+
return { query: query, values: [] };
|
|
337
330
|
}
|
|
338
331
|
|
|
339
332
|
// Extract content and handle escaped quotes
|
|
@@ -396,13 +389,13 @@ var webDb = /** @class */ (function () {
|
|
|
396
389
|
|
|
397
390
|
// If we didn't find any bindable literals, don't treat as prepared
|
|
398
391
|
if (values.length === 0) {
|
|
399
|
-
return {
|
|
392
|
+
return { query: query, values: [] };
|
|
400
393
|
}
|
|
401
394
|
|
|
402
|
-
return {
|
|
395
|
+
return { query: preparedQuery, values: values };
|
|
403
396
|
} catch (err) {
|
|
404
397
|
console.warn('Error parsing query to prepared statement:', err);
|
|
405
|
-
return {
|
|
398
|
+
return { query: query, values: [] };
|
|
406
399
|
}
|
|
407
400
|
};
|
|
408
401
|
|