@capacitor-community/sqlite 5.0.7-2 → 5.0.8
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 +17 -2
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +126 -3
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +115 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +142 -80
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +9 -9
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsDelete.java +484 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsDrop.java +3 -3
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLStatement.java +169 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsUpgrade.java +4 -4
- package/dist/esm/definitions.d.ts +117 -13
- package/dist/esm/definitions.js +103 -51
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -0
- package/dist/esm/web.js +44 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +147 -51
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +147 -51
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +605 -181
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorSQLite.swift +123 -2
- package/ios/Plugin/CapacitorSQLitePlugin.m +4 -0
- package/ios/Plugin/CapacitorSQLitePlugin.swift +131 -1
- package/ios/Plugin/Database.swift +79 -2
- package/ios/Plugin/ImportExportJson/ImportFromJson.swift +13 -2
- package/ios/Plugin/Utils/UtilsDelete.swift +119 -117
- package/ios/Plugin/Utils/UtilsSQLCipher.swift +13 -5
- package/ios/Plugin/Utils/UtilsSQLStatement.swift +84 -84
- package/ios/Plugin/Utils/UtilsUpgrade.swift +3 -0
- package/package.json +5 -2
- package/src/definitions.ts +214 -57
- package/src/web.ts +48 -0
package/dist/plugin.js
CHANGED
|
@@ -448,6 +448,8 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
448
448
|
return this.readonly;
|
|
449
449
|
}
|
|
450
450
|
async open() {
|
|
451
|
+
const jeepSQlEL = document.querySelector("jeep-sqlite");
|
|
452
|
+
console.log(`in definition open jeepSQlEL: `, jeepSQlEL);
|
|
451
453
|
try {
|
|
452
454
|
await this.sqlite.open({
|
|
453
455
|
database: this.dbName,
|
|
@@ -471,40 +473,69 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
471
473
|
return Promise.reject(err);
|
|
472
474
|
}
|
|
473
475
|
}
|
|
476
|
+
async beginTransaction() {
|
|
477
|
+
try {
|
|
478
|
+
const changes = await this.sqlite
|
|
479
|
+
.beginTransaction({ database: this.dbName });
|
|
480
|
+
return Promise.resolve(changes);
|
|
481
|
+
}
|
|
482
|
+
catch (err) {
|
|
483
|
+
return Promise.reject(err);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
async commitTransaction() {
|
|
487
|
+
try {
|
|
488
|
+
const changes = await this.sqlite
|
|
489
|
+
.commitTransaction({ database: this.dbName });
|
|
490
|
+
return Promise.resolve(changes);
|
|
491
|
+
}
|
|
492
|
+
catch (err) {
|
|
493
|
+
return Promise.reject(err);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
async rollbackTransaction() {
|
|
497
|
+
try {
|
|
498
|
+
const changes = await this.sqlite
|
|
499
|
+
.rollbackTransaction({ database: this.dbName });
|
|
500
|
+
return Promise.resolve(changes);
|
|
501
|
+
}
|
|
502
|
+
catch (err) {
|
|
503
|
+
return Promise.reject(err);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
async isTransactionActive() {
|
|
507
|
+
try {
|
|
508
|
+
const result = await this.sqlite
|
|
509
|
+
.isTransactionActive({ database: this.dbName });
|
|
510
|
+
return Promise.resolve(result);
|
|
511
|
+
}
|
|
512
|
+
catch (err) {
|
|
513
|
+
return Promise.reject(err);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
474
516
|
async loadExtension(path) {
|
|
475
517
|
try {
|
|
476
|
-
console.log(`database: ${this.dbName}`);
|
|
477
|
-
console.log(`readonly: ${this.readonly}}`);
|
|
478
|
-
console.log(`path: ${path}}`);
|
|
479
518
|
await this.sqlite.loadExtension({
|
|
480
519
|
database: this.dbName,
|
|
481
520
|
path: path,
|
|
482
521
|
readonly: this.readonly,
|
|
483
522
|
});
|
|
484
|
-
console.log(`loadExtension successful`);
|
|
485
523
|
return Promise.resolve();
|
|
486
524
|
}
|
|
487
525
|
catch (err) {
|
|
488
|
-
console.log(`loadExtension failed `);
|
|
489
526
|
return Promise.reject(err);
|
|
490
527
|
}
|
|
491
528
|
}
|
|
492
529
|
async enableLoadExtension(toggle) {
|
|
493
530
|
try {
|
|
494
|
-
console.log(`database: ${this.dbName}`);
|
|
495
|
-
console.log(`readonly: ${this.readonly}`);
|
|
496
|
-
console.log(`toggle: ${toggle}`);
|
|
497
531
|
await this.sqlite.enableLoadExtension({
|
|
498
532
|
database: this.dbName,
|
|
499
533
|
toggle: toggle,
|
|
500
534
|
readonly: this.readonly,
|
|
501
535
|
});
|
|
502
|
-
console.log(`enableLoadExtension successful`);
|
|
503
536
|
return Promise.resolve();
|
|
504
537
|
}
|
|
505
538
|
catch (err) {
|
|
506
|
-
console.log(err);
|
|
507
|
-
console.log(`enableLoadExtension failed `);
|
|
508
539
|
return Promise.reject(err);
|
|
509
540
|
}
|
|
510
541
|
}
|
|
@@ -544,7 +575,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
544
575
|
return Promise.reject(err);
|
|
545
576
|
}
|
|
546
577
|
}
|
|
547
|
-
async execute(statements, transaction = true) {
|
|
578
|
+
async execute(statements, transaction = true, isSQL92 = true) {
|
|
548
579
|
try {
|
|
549
580
|
if (!this.readonly) {
|
|
550
581
|
const res = await this.sqlite.execute({
|
|
@@ -552,6 +583,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
552
583
|
statements: statements,
|
|
553
584
|
transaction: transaction,
|
|
554
585
|
readonly: false,
|
|
586
|
+
isSQL92: isSQL92
|
|
555
587
|
});
|
|
556
588
|
return Promise.resolve(res);
|
|
557
589
|
}
|
|
@@ -563,7 +595,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
563
595
|
return Promise.reject(err);
|
|
564
596
|
}
|
|
565
597
|
}
|
|
566
|
-
async query(statement, values) {
|
|
598
|
+
async query(statement, values, isSQL92 = true) {
|
|
567
599
|
let res;
|
|
568
600
|
try {
|
|
569
601
|
if (values && values.length > 0) {
|
|
@@ -572,6 +604,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
572
604
|
statement: statement,
|
|
573
605
|
values: values,
|
|
574
606
|
readonly: this.readonly,
|
|
607
|
+
isSql92: true
|
|
575
608
|
});
|
|
576
609
|
}
|
|
577
610
|
else {
|
|
@@ -580,6 +613,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
580
613
|
statement: statement,
|
|
581
614
|
values: [],
|
|
582
615
|
readonly: this.readonly,
|
|
616
|
+
isSQL92: isSQL92
|
|
583
617
|
});
|
|
584
618
|
}
|
|
585
619
|
// reorder rows for ios
|
|
@@ -590,7 +624,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
590
624
|
return Promise.reject(err);
|
|
591
625
|
}
|
|
592
626
|
}
|
|
593
|
-
async run(statement, values, transaction = true, returnMode = 'no') {
|
|
627
|
+
async run(statement, values, transaction = true, returnMode = 'no', isSQL92 = true) {
|
|
594
628
|
let res;
|
|
595
629
|
try {
|
|
596
630
|
if (!this.readonly) {
|
|
@@ -605,6 +639,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
605
639
|
transaction: transaction,
|
|
606
640
|
readonly: false,
|
|
607
641
|
returnMode: mRetMode,
|
|
642
|
+
isSQL92: true
|
|
608
643
|
});
|
|
609
644
|
// }
|
|
610
645
|
}
|
|
@@ -619,6 +654,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
619
654
|
transaction: transaction,
|
|
620
655
|
readonly: false,
|
|
621
656
|
returnMode: mRetMode,
|
|
657
|
+
isSQL92: isSQL92
|
|
622
658
|
});
|
|
623
659
|
}
|
|
624
660
|
// reorder rows for ios
|
|
@@ -633,7 +669,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
633
669
|
return Promise.reject(err);
|
|
634
670
|
}
|
|
635
671
|
}
|
|
636
|
-
async executeSet(set, transaction = true, returnMode = 'no') {
|
|
672
|
+
async executeSet(set, transaction = true, returnMode = 'no', isSQL92 = true) {
|
|
637
673
|
let res;
|
|
638
674
|
try {
|
|
639
675
|
if (!this.readonly) {
|
|
@@ -643,6 +679,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
643
679
|
transaction: transaction,
|
|
644
680
|
readonly: false,
|
|
645
681
|
returnMode: returnMode,
|
|
682
|
+
isSQL92: isSQL92
|
|
646
683
|
});
|
|
647
684
|
// }
|
|
648
685
|
// reorder rows for ios
|
|
@@ -761,12 +798,13 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
761
798
|
return Promise.reject(err);
|
|
762
799
|
}
|
|
763
800
|
}
|
|
764
|
-
async exportToJson(mode) {
|
|
801
|
+
async exportToJson(mode, encrypted = false) {
|
|
765
802
|
try {
|
|
766
803
|
const res = await this.sqlite.exportToJson({
|
|
767
804
|
database: this.dbName,
|
|
768
805
|
jsonexportmode: mode,
|
|
769
806
|
readonly: this.readonly,
|
|
807
|
+
encrypted: encrypted,
|
|
770
808
|
});
|
|
771
809
|
return Promise.resolve(res);
|
|
772
810
|
}
|
|
@@ -791,17 +829,25 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
791
829
|
return Promise.reject(err);
|
|
792
830
|
}
|
|
793
831
|
}
|
|
794
|
-
async executeTransaction(txn) {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
832
|
+
async executeTransaction(txn, isSQL92 = true) {
|
|
833
|
+
let changes = 0;
|
|
834
|
+
let isActive = false;
|
|
835
|
+
if (!this.readonly) {
|
|
836
|
+
try {
|
|
837
|
+
await this.sqlite.beginTransaction({
|
|
838
|
+
database: this.dbName
|
|
839
|
+
});
|
|
840
|
+
isActive = await this.sqlite.isTransactionActive({
|
|
841
|
+
database: this.dbName
|
|
801
842
|
});
|
|
802
|
-
if (
|
|
803
|
-
return Promise.reject('
|
|
843
|
+
if (!isActive) {
|
|
844
|
+
return Promise.reject('After Begin Transaction, no transaction active');
|
|
804
845
|
}
|
|
846
|
+
}
|
|
847
|
+
catch (err) {
|
|
848
|
+
return Promise.reject(err);
|
|
849
|
+
}
|
|
850
|
+
try {
|
|
805
851
|
for (const task of txn) {
|
|
806
852
|
if (task.values && task.values.length > 0) {
|
|
807
853
|
const retMode = task.statement.toUpperCase().includes('RETURNING')
|
|
@@ -814,11 +860,12 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
814
860
|
transaction: false,
|
|
815
861
|
readonly: false,
|
|
816
862
|
returnMode: retMode,
|
|
863
|
+
isSQL92: isSQL92
|
|
817
864
|
});
|
|
818
|
-
if (ret.changes.
|
|
819
|
-
|
|
820
|
-
return Promise.reject('Error in transaction run ');
|
|
865
|
+
if (ret.changes.changes <= 0) {
|
|
866
|
+
throw new Error('Error in transaction method run ');
|
|
821
867
|
}
|
|
868
|
+
changes += ret.changes.changes;
|
|
822
869
|
}
|
|
823
870
|
else {
|
|
824
871
|
const ret = await this.sqlite.execute({
|
|
@@ -827,37 +874,42 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
827
874
|
transaction: false,
|
|
828
875
|
readonly: false,
|
|
829
876
|
});
|
|
877
|
+
isActive = await this.sqlite.isTransactionActive({
|
|
878
|
+
database: this.dbName
|
|
879
|
+
});
|
|
830
880
|
if (ret.changes.changes < 0) {
|
|
831
|
-
|
|
832
|
-
database: this.dbName,
|
|
833
|
-
statements: 'ROLLBACK;',
|
|
834
|
-
transaction: false,
|
|
835
|
-
readonly: false,
|
|
836
|
-
});
|
|
837
|
-
return Promise.reject('Error in transaction execute ');
|
|
881
|
+
throw new Error('Error in transaction method execute ');
|
|
838
882
|
}
|
|
883
|
+
changes += ret.changes.changes;
|
|
839
884
|
}
|
|
840
885
|
}
|
|
841
|
-
await this.sqlite.
|
|
842
|
-
database: this.dbName
|
|
843
|
-
statements: 'COMMIT;',
|
|
844
|
-
transaction: false,
|
|
845
|
-
readonly: false,
|
|
886
|
+
isActive = await this.sqlite.isTransactionActive({
|
|
887
|
+
database: this.dbName
|
|
846
888
|
});
|
|
847
|
-
|
|
889
|
+
if (isActive) {
|
|
890
|
+
const retC = await this.sqlite.commitTransaction({
|
|
891
|
+
database: this.dbName
|
|
892
|
+
});
|
|
893
|
+
changes += retC.changes.changes;
|
|
894
|
+
}
|
|
895
|
+
const retChanges = { changes: { changes: changes } };
|
|
896
|
+
return Promise.resolve(retChanges);
|
|
848
897
|
}
|
|
849
|
-
|
|
850
|
-
|
|
898
|
+
catch (err) {
|
|
899
|
+
const msg = err.message ? err.message : err;
|
|
900
|
+
isActive = await this.sqlite.isTransactionActive({
|
|
901
|
+
database: this.dbName
|
|
902
|
+
});
|
|
903
|
+
if (isActive) {
|
|
904
|
+
await this.sqlite.rollbackTransaction({
|
|
905
|
+
database: this.dbName,
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
return Promise.reject(msg);
|
|
851
909
|
}
|
|
852
910
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
database: this.dbName,
|
|
856
|
-
statements: 'ROLLBACK;',
|
|
857
|
-
transaction: false,
|
|
858
|
-
readonly: false,
|
|
859
|
-
});
|
|
860
|
-
return Promise.reject(err);
|
|
911
|
+
else {
|
|
912
|
+
return Promise.reject('not allowed in read-only mode');
|
|
861
913
|
}
|
|
862
914
|
}
|
|
863
915
|
async reorderRows(res) {
|
|
@@ -1019,6 +1071,50 @@ var capacitorCapacitorSQLite = (function (exports, core) {
|
|
|
1019
1071
|
throw new Error(`${err}`);
|
|
1020
1072
|
}
|
|
1021
1073
|
}
|
|
1074
|
+
async beginTransaction(options) {
|
|
1075
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1076
|
+
this.ensureWebstoreIsOpen();
|
|
1077
|
+
try {
|
|
1078
|
+
const changes = await this.jeepSqliteElement.beginTransaction(options);
|
|
1079
|
+
return changes;
|
|
1080
|
+
}
|
|
1081
|
+
catch (err) {
|
|
1082
|
+
throw new Error(`${err}`);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
async commitTransaction(options) {
|
|
1086
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1087
|
+
this.ensureWebstoreIsOpen();
|
|
1088
|
+
try {
|
|
1089
|
+
const changes = await this.jeepSqliteElement.commitTransaction(options);
|
|
1090
|
+
return changes;
|
|
1091
|
+
}
|
|
1092
|
+
catch (err) {
|
|
1093
|
+
throw new Error(`${err}`);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
async rollbackTransaction(options) {
|
|
1097
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1098
|
+
this.ensureWebstoreIsOpen();
|
|
1099
|
+
try {
|
|
1100
|
+
const changes = await this.jeepSqliteElement.rollbackTransaction(options);
|
|
1101
|
+
return changes;
|
|
1102
|
+
}
|
|
1103
|
+
catch (err) {
|
|
1104
|
+
throw new Error(`${err}`);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
async isTransactionActive(options) {
|
|
1108
|
+
this.ensureJeepSqliteIsAvailable();
|
|
1109
|
+
this.ensureWebstoreIsOpen();
|
|
1110
|
+
try {
|
|
1111
|
+
const result = await this.jeepSqliteElement.isTransactionActive(options);
|
|
1112
|
+
return result;
|
|
1113
|
+
}
|
|
1114
|
+
catch (err) {
|
|
1115
|
+
throw new Error(`${err}`);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1022
1118
|
async getTableList(options) {
|
|
1023
1119
|
this.ensureJeepSqliteIsAvailable();
|
|
1024
1120
|
this.ensureWebstoreIsOpen();
|