@capacitor-community/sqlite 4.1.0-4 → 4.1.0-5
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/electron/dist/plugin.js
CHANGED
|
@@ -43,10 +43,6 @@ class UtilsSQLite {
|
|
|
43
43
|
password: string,*/) {
|
|
44
44
|
const msg = 'OpenOrCreateDatabase: ';
|
|
45
45
|
// open sqlite3 database
|
|
46
|
-
/* const mDB: any = new this.JSQlite.Database(pathDB, {
|
|
47
|
-
verbose: console.log,
|
|
48
|
-
});
|
|
49
|
-
*/
|
|
50
46
|
const mDB = new this.SQLite3.Database(pathDB, {
|
|
51
47
|
verbose: console.log,
|
|
52
48
|
});
|
|
@@ -345,9 +341,7 @@ class UtilsSQLite {
|
|
|
345
341
|
if (trimStmt === 'DELETE FROM' &&
|
|
346
342
|
stmt.toLowerCase().includes('WHERE'.toLowerCase())) {
|
|
347
343
|
const whereStmt = `${stmt.trim()};`;
|
|
348
|
-
console.log(`in utilsSQLite execute whereStmt ${whereStmt}`);
|
|
349
344
|
const rStmt = await this.deleteSQL(mDB, whereStmt, []);
|
|
350
|
-
console.log(`in utilsSQLite execute rStmt ${rStmt}`);
|
|
351
345
|
resArr.push(rStmt);
|
|
352
346
|
}
|
|
353
347
|
else {
|
|
@@ -356,7 +350,6 @@ class UtilsSQLite {
|
|
|
356
350
|
}
|
|
357
351
|
sqlStmt = resArr.join(';');
|
|
358
352
|
}
|
|
359
|
-
console.log(`in utilsSQLite execute sqlStmt ${sqlStmt}`);
|
|
360
353
|
await this.execDB(mDB, sqlStmt);
|
|
361
354
|
changes = (await this.dbChanges(mDB)) - initChanges;
|
|
362
355
|
return Promise.resolve(changes);
|
|
@@ -448,7 +441,6 @@ class UtilsSQLite {
|
|
|
448
441
|
async runExec(db, stmt, values = []) {
|
|
449
442
|
return new Promise((resolve, reject) => {
|
|
450
443
|
if (values != null && values.length > 0) {
|
|
451
|
-
console.log(`in runExec stmt: ${stmt} values: ${values}`);
|
|
452
444
|
db.run(stmt, values, (err) => {
|
|
453
445
|
if (err) {
|
|
454
446
|
console.log(`in runExec err1: ${JSON.stringify(err)}`);
|
|
@@ -512,7 +504,6 @@ class UtilsSQLite {
|
|
|
512
504
|
.substring('DELETE FROM'.length)
|
|
513
505
|
.trim();
|
|
514
506
|
sqlStmt = `UPDATE ${tableName} SET sql_deleted = 1 ${clauseStmt}`;
|
|
515
|
-
console.log(`in deleteSQL sqlStmt: ${sqlStmt}`);
|
|
516
507
|
// Find REFERENCES if any and update the sql_deleted column
|
|
517
508
|
await this.findReferencesAndUpdate(db, tableName, clauseStmt, values);
|
|
518
509
|
}
|
|
@@ -537,31 +528,24 @@ class UtilsSQLite {
|
|
|
537
528
|
return;
|
|
538
529
|
}
|
|
539
530
|
const tableNameWithRefs = references.pop();
|
|
540
|
-
console.log(`references: ${references}`);
|
|
541
|
-
console.log(`tableNameWithRefs: ${tableNameWithRefs}`);
|
|
542
531
|
for (const refe of references) {
|
|
543
532
|
// get the tableName of the reference
|
|
544
533
|
const refTable = await this.getReferenceTableName(refe);
|
|
545
534
|
if (refTable.length <= 0) {
|
|
546
535
|
continue;
|
|
547
536
|
}
|
|
548
|
-
console.log(`refTable: ${refTable}`);
|
|
549
537
|
// get the with references columnName
|
|
550
538
|
const withRefsNames = await this.getWithRefsColumnName(refe);
|
|
551
|
-
console.log(`withRefsNames: ${withRefsNames}`);
|
|
552
539
|
if (withRefsNames.length <= 0) {
|
|
553
540
|
continue;
|
|
554
541
|
}
|
|
555
542
|
// get the referenced columnName
|
|
556
543
|
const colNames = await this.getReferencedColumnName(refe);
|
|
557
|
-
console.log(`colNames: ${colNames}`);
|
|
558
544
|
if (colNames.length <= 0) {
|
|
559
545
|
continue;
|
|
560
546
|
}
|
|
561
547
|
// update the where clause
|
|
562
548
|
const uWhereStmt = await this.updateWhere(whereStmt, withRefsNames, colNames);
|
|
563
|
-
console.log(`whereStmt: ${whereStmt}`);
|
|
564
|
-
console.log(`uWhereStmt: ${uWhereStmt}`);
|
|
565
549
|
if (uWhereStmt.length <= 0) {
|
|
566
550
|
continue;
|
|
567
551
|
}
|
|
@@ -571,31 +555,22 @@ class UtilsSQLite {
|
|
|
571
555
|
updTableName = refTable;
|
|
572
556
|
updColNames = withRefsNames;
|
|
573
557
|
}
|
|
574
|
-
console.log(`updTableName: ${updTableName}`);
|
|
575
|
-
console.log(`updColNames: ${updColNames}`);
|
|
576
558
|
//update sql_deleted for this reference
|
|
577
559
|
const stmt = 'UPDATE ' + updTableName + ' SET sql_deleted = 1 ' + uWhereStmt;
|
|
578
|
-
console.log(`stmt: ${stmt}`);
|
|
579
|
-
console.log(`values: ${values}`);
|
|
580
560
|
if (values != null && values.length > 0) {
|
|
581
561
|
const mVal = await this.replaceUndefinedByNull(values);
|
|
582
562
|
let arrVal = whereStmt.split('?');
|
|
583
563
|
if (arrVal[arrVal.length - 1] === ';')
|
|
584
564
|
arrVal = arrVal.slice(0, -1);
|
|
585
|
-
console.log(`arrVal: ${arrVal}`);
|
|
586
565
|
const selValues = [];
|
|
587
566
|
for (const [j, val] of arrVal.entries()) {
|
|
588
|
-
console.log(`j: ${j} val: ${val}`);
|
|
589
567
|
for (const updVal of updColNames) {
|
|
590
568
|
const idxVal = val.indexOf(updVal);
|
|
591
|
-
console.log(`updVal: ${updVal} idxVal ${idxVal}`);
|
|
592
569
|
if (idxVal > -1) {
|
|
593
570
|
selValues.push(mVal[j]);
|
|
594
571
|
}
|
|
595
572
|
}
|
|
596
573
|
}
|
|
597
|
-
console.log(`*** stmt: ${selValues}`);
|
|
598
|
-
console.log(`*** selValues: ${selValues}`);
|
|
599
574
|
await db.run(stmt, selValues);
|
|
600
575
|
}
|
|
601
576
|
else {
|
|
@@ -2808,10 +2783,13 @@ class UtilsFile {
|
|
|
2808
2783
|
*/
|
|
2809
2784
|
getAssetsDatabasesPath() {
|
|
2810
2785
|
let retPath = '';
|
|
2811
|
-
const
|
|
2812
|
-
const webDir = JSON.parse(rawdata).webDir;
|
|
2786
|
+
const webDir = this.capConfig.webDir;
|
|
2813
2787
|
const dir = webDir === 'www' ? 'src' : 'public';
|
|
2814
|
-
|
|
2788
|
+
let mAppPath = this.appPath;
|
|
2789
|
+
if (this.Path.basename(this.appPath) === "electron") {
|
|
2790
|
+
mAppPath = this.Path.dirname(this.appPath);
|
|
2791
|
+
}
|
|
2792
|
+
retPath = this.Path.resolve(mAppPath, dir, 'assets', 'databases');
|
|
2815
2793
|
return retPath;
|
|
2816
2794
|
}
|
|
2817
2795
|
/**
|