@unvired/cordova-plugin-unvired-electron-db 0.0.41 → 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 -27
- 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,28 +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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
stmt.free();
|
|
41
|
-
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);
|
|
42
40
|
} else {
|
|
43
|
-
|
|
44
|
-
const parsedQuery = webDb.parseQueryToPrepared(query);
|
|
45
|
-
if (parsedQuery.isPrepared) {
|
|
46
|
-
var stmt = db.prepare(parsedQuery.query);
|
|
47
|
-
stmt.run(parsedQuery.values);
|
|
48
|
-
stmt.free();
|
|
49
|
-
} else {
|
|
50
|
-
// Fallback to exec for queries without parameters
|
|
51
|
-
db.exec(query);
|
|
52
|
-
}
|
|
53
|
-
sucessCallback("Success");
|
|
41
|
+
stmt = db.prepare(query);
|
|
54
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);
|
|
55
52
|
}
|
|
56
53
|
catch (err) {
|
|
57
54
|
console.error("Error executing query: " + query, err);
|
|
@@ -248,7 +245,7 @@ var webDb = /** @class */ (function () {
|
|
|
248
245
|
|
|
249
246
|
// If query already contains positional placeholders, don't attempt to re-parameterize it.
|
|
250
247
|
if (query.indexOf('?') !== -1) {
|
|
251
|
-
return {
|
|
248
|
+
return { query: query, values: [] };
|
|
252
249
|
}
|
|
253
250
|
if (queryUpper.startsWith('CREATE') ||
|
|
254
251
|
queryUpper.startsWith('DROP') ||
|
|
@@ -272,7 +269,7 @@ var webDb = /** @class */ (function () {
|
|
|
272
269
|
// DDL/transactional statements and similar should not be parameterized.
|
|
273
270
|
// Note: INSERT ... VALUES will be parameterized below so large
|
|
274
271
|
// string/numeric literals (eg. base64 blobs) can be bound safely.
|
|
275
|
-
return {
|
|
272
|
+
return { query: query, values: [] };
|
|
276
273
|
}
|
|
277
274
|
|
|
278
275
|
|
|
@@ -281,7 +278,7 @@ var webDb = /** @class */ (function () {
|
|
|
281
278
|
const hasNumericLiterals = /\b\d+\.?\d*\b/.test(query);
|
|
282
279
|
|
|
283
280
|
if (!hasStringLiterals && !hasNumericLiterals) {
|
|
284
|
-
return {
|
|
281
|
+
return { query: query, values: [] };
|
|
285
282
|
}
|
|
286
283
|
|
|
287
284
|
// We'll scan the original query left-to-right and replace literals with
|
|
@@ -329,7 +326,7 @@ var webDb = /** @class */ (function () {
|
|
|
329
326
|
|
|
330
327
|
if (!closed) {
|
|
331
328
|
// Unmatched quote; bail out to safe fallback to avoid errors
|
|
332
|
-
return {
|
|
329
|
+
return { query: query, values: [] };
|
|
333
330
|
}
|
|
334
331
|
|
|
335
332
|
// Extract content and handle escaped quotes
|
|
@@ -392,13 +389,13 @@ var webDb = /** @class */ (function () {
|
|
|
392
389
|
|
|
393
390
|
// If we didn't find any bindable literals, don't treat as prepared
|
|
394
391
|
if (values.length === 0) {
|
|
395
|
-
return {
|
|
392
|
+
return { query: query, values: [] };
|
|
396
393
|
}
|
|
397
394
|
|
|
398
|
-
return {
|
|
395
|
+
return { query: preparedQuery, values: values };
|
|
399
396
|
} catch (err) {
|
|
400
397
|
console.warn('Error parsing query to prepared statement:', err);
|
|
401
|
-
return {
|
|
398
|
+
return { query: query, values: [] };
|
|
402
399
|
}
|
|
403
400
|
};
|
|
404
401
|
|