@capacitor-community/sqlite 4.2.1 → 4.2.2-1
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
|
@@ -218,14 +218,19 @@ class UtilsSQLite {
|
|
|
218
218
|
* BeginTransaction
|
|
219
219
|
* @param db
|
|
220
220
|
* @param isOpen
|
|
221
|
+
* @param mode
|
|
221
222
|
*/
|
|
222
|
-
async beginTransaction(db, isOpen) {
|
|
223
|
+
async beginTransaction(db, isOpen, mode) {
|
|
224
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
223
225
|
return new Promise((resolve, reject) => {
|
|
224
226
|
const msg = 'BeginTransaction: ';
|
|
225
227
|
if (!isOpen) {
|
|
226
228
|
return Promise.reject(`${msg}database not opened`);
|
|
227
229
|
}
|
|
228
|
-
|
|
230
|
+
let sql = 'BEGIN TRANSACTION;';
|
|
231
|
+
if (mode.slice(0, 3) === "wal") {
|
|
232
|
+
sql = "BEGIN CONCURRENT";
|
|
233
|
+
}
|
|
229
234
|
db.run(sql, (err) => {
|
|
230
235
|
if (err) {
|
|
231
236
|
reject(`${msg}${err.message}`);
|
|
@@ -823,6 +828,23 @@ class UtilsSQLite {
|
|
|
823
828
|
return Promise.reject(`isSqlDeleted: ${err}`);
|
|
824
829
|
}
|
|
825
830
|
}
|
|
831
|
+
async getJournalMode(mDB) {
|
|
832
|
+
let resQuery = [];
|
|
833
|
+
let retMode = "delete";
|
|
834
|
+
const query = `PRAGMA journal_mode;`;
|
|
835
|
+
try {
|
|
836
|
+
resQuery = await this.queryAll(mDB, query, []);
|
|
837
|
+
if (resQuery.length === 1) {
|
|
838
|
+
for (const query of resQuery) {
|
|
839
|
+
retMode = query.journal_mode;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return retMode;
|
|
843
|
+
}
|
|
844
|
+
catch (err) {
|
|
845
|
+
return Promise.reject('GetJournalMode: ' + `${err}`);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
826
848
|
/**
|
|
827
849
|
* GetTableColumnNamesTypes
|
|
828
850
|
* @param mDB
|
|
@@ -927,7 +949,8 @@ class UtilsJson {
|
|
|
927
949
|
let changes = 0;
|
|
928
950
|
try {
|
|
929
951
|
// start a transaction
|
|
930
|
-
await this.sqliteUtil.
|
|
952
|
+
const mode = await this.sqliteUtil.getJournalMode(mDB);
|
|
953
|
+
await this.sqliteUtil.beginTransaction(mDB, true, mode);
|
|
931
954
|
}
|
|
932
955
|
catch (err) {
|
|
933
956
|
return Promise.reject(`CreateDatabaseSchema: ${err}`);
|
|
@@ -2563,7 +2586,8 @@ class ImportFromJson {
|
|
|
2563
2586
|
try {
|
|
2564
2587
|
initChanges = await this.sqliteUtil.dbChanges(mDB);
|
|
2565
2588
|
// start a transaction
|
|
2566
|
-
await this.sqliteUtil.
|
|
2589
|
+
const mode = await this.sqliteUtil.getJournalMode(mDB);
|
|
2590
|
+
await this.sqliteUtil.beginTransaction(mDB, true, mode);
|
|
2567
2591
|
}
|
|
2568
2592
|
catch (err) {
|
|
2569
2593
|
return Promise.reject(`createTablesData: ${err}`);
|
|
@@ -2623,7 +2647,8 @@ class ImportFromJson {
|
|
|
2623
2647
|
try {
|
|
2624
2648
|
initChanges = await this.sqliteUtil.dbChanges(mDB);
|
|
2625
2649
|
// start a transaction
|
|
2626
|
-
await this.sqliteUtil.
|
|
2650
|
+
const mode = await this.sqliteUtil.getJournalMode(mDB);
|
|
2651
|
+
await this.sqliteUtil.beginTransaction(mDB, true, mode);
|
|
2627
2652
|
}
|
|
2628
2653
|
catch (err) {
|
|
2629
2654
|
return Promise.reject(`createViews: ${err}`);
|
|
@@ -3273,7 +3298,8 @@ class UtilsUpgrade {
|
|
|
3273
3298
|
*/
|
|
3274
3299
|
async executeStatementsProcess(mDB, statements) {
|
|
3275
3300
|
try {
|
|
3276
|
-
await this.sqliteUtil.
|
|
3301
|
+
const mode = await this.sqliteUtil.getJournalMode(mDB);
|
|
3302
|
+
await this.sqliteUtil.beginTransaction(mDB, true, mode);
|
|
3277
3303
|
for (const statement of statements) {
|
|
3278
3304
|
await this.sqliteUtil.execute(mDB, statement, false);
|
|
3279
3305
|
}
|
|
@@ -3584,7 +3610,8 @@ class Database {
|
|
|
3584
3610
|
this.ensureDatabaseIsOpen();
|
|
3585
3611
|
try {
|
|
3586
3612
|
if (transaction) {
|
|
3587
|
-
await this.sqliteUtil.
|
|
3613
|
+
const mode = await this.sqliteUtil.getJournalMode(this.database);
|
|
3614
|
+
await this.sqliteUtil.beginTransaction(this.database, this._isDbOpen, mode);
|
|
3588
3615
|
}
|
|
3589
3616
|
const changes = await this.sqliteUtil.execute(this.database, sql, false);
|
|
3590
3617
|
if (changes < 0) {
|
|
@@ -3640,7 +3667,8 @@ class Database {
|
|
|
3640
3667
|
initChanges = await this.sqliteUtil.dbChanges(this.database);
|
|
3641
3668
|
// start a transaction
|
|
3642
3669
|
if (transaction) {
|
|
3643
|
-
await this.sqliteUtil.
|
|
3670
|
+
const mode = await this.sqliteUtil.getJournalMode(this.database);
|
|
3671
|
+
await this.sqliteUtil.beginTransaction(this.database, this._isDbOpen, mode);
|
|
3644
3672
|
}
|
|
3645
3673
|
}
|
|
3646
3674
|
catch (err) {
|
|
@@ -3683,7 +3711,8 @@ class Database {
|
|
|
3683
3711
|
initChanges = await this.sqliteUtil.dbChanges(this.database);
|
|
3684
3712
|
// start a transaction
|
|
3685
3713
|
if (transaction) {
|
|
3686
|
-
await this.sqliteUtil.
|
|
3714
|
+
const mode = await this.sqliteUtil.getJournalMode(this.database);
|
|
3715
|
+
await this.sqliteUtil.beginTransaction(this.database, this._isDbOpen, mode);
|
|
3687
3716
|
}
|
|
3688
3717
|
}
|
|
3689
3718
|
catch (err) {
|