@capacitor-community/sqlite 4.2.2-1 → 4.5.0
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 +8 -4
- package/electron/dist/plugin.js +14 -21
- package/electron/dist/plugin.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
<a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/dw/@capacitor-community/sqlite?style=flat-square" /></a>
|
|
17
17
|
<a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/v/@capacitor-community/sqlite?style=flat-square" /></a>
|
|
18
18
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
19
|
-
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-
|
|
19
|
+
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-24-orange?style=flat-square" /></a>
|
|
20
20
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
|
+
|
|
23
24
|
## Maintainers
|
|
24
25
|
|
|
25
26
|
| Maintainer | GitHub | Social |
|
|
@@ -94,6 +95,7 @@ npm install --save jszip
|
|
|
94
95
|
npm install --save node-fetch
|
|
95
96
|
npm install --save-dev @types/sqlite3
|
|
96
97
|
```
|
|
98
|
+
- **Important**: `node-fetch` version must be `<=2.6.7`; otherwise [you'll get an error](https://github.com/capacitor-community/sqlite/issues/349 "you'll get an error ERR_REQUIRE_ESM") running the app.
|
|
97
99
|
|
|
98
100
|
## IOS Quirks
|
|
99
101
|
|
|
@@ -223,9 +225,9 @@ npm install --save-dev @types/sqlite3
|
|
|
223
225
|
## Dependencies
|
|
224
226
|
|
|
225
227
|
The iOS and Android codes are using `SQLCipher` allowing for database encryption.
|
|
226
|
-
The iOS codes is using `ZIPFoundation` for unzipping assets files
|
|
228
|
+
The iOS codes is using `ZIPFoundation` for unzipping assets files.
|
|
227
229
|
The Electron code is using `sqlite3` and `node-fetch` from 4.2.0.
|
|
228
|
-
The Web code is using the Stencil component `jeep-sqlite` based on `sql.js`, `localforage
|
|
230
|
+
The Web code is using the Stencil component `jeep-sqlite` based on `sql.js`, `localforage`, and `jszip`.
|
|
229
231
|
|
|
230
232
|
## Contributors ✨
|
|
231
233
|
|
|
@@ -256,7 +258,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
256
258
|
<a href="https://github.com/antoniovlx" title="antoniovlx"><img src="https://github.com/antoniovlx.png?size=100" width="50" height="50" /></a>
|
|
257
259
|
<a href="https://github.com/HarelM" title="HarelM"><img src="https://github.com/HarelM.png?size=100" width="50" height="50" /></a>
|
|
258
260
|
<a href="https://github.com/rdlabo" title="rdlabo"><img src="https://github.com/rdlabo.png?size=100" width="50" height="50" /></a>
|
|
259
|
-
<a href="https://github.com/axkristiansen" title="
|
|
261
|
+
<a href="https://github.com/axkristiansen" title="axkristiansen"><img src="https://github.com/axkristiansen.png?size=100" width="50" height="50" /></a>
|
|
262
|
+
<a href="https://github.com/aeinn" title="aeinn"><img src="https://github.com/aeinn.png?size=100" width="50" height="50" /></a>
|
|
263
|
+
<a href="https://github.com/https://github.com/jonz94" title="aeinn"><img src="https://github.com/jonz94.png?size=100" width="50" height="50" /></a>
|
|
260
264
|
</p>
|
|
261
265
|
|
|
262
266
|
<!-- markdownlint-enable -->
|
package/electron/dist/plugin.js
CHANGED
|
@@ -218,19 +218,15 @@ class UtilsSQLite {
|
|
|
218
218
|
* BeginTransaction
|
|
219
219
|
* @param db
|
|
220
220
|
* @param isOpen
|
|
221
|
-
* @param mode
|
|
222
221
|
*/
|
|
223
|
-
async beginTransaction(db, isOpen
|
|
222
|
+
async beginTransaction(db, isOpen) {
|
|
224
223
|
// eslint-disable-next-line no-async-promise-executor
|
|
225
224
|
return new Promise((resolve, reject) => {
|
|
226
225
|
const msg = 'BeginTransaction: ';
|
|
227
226
|
if (!isOpen) {
|
|
228
227
|
return Promise.reject(`${msg}database not opened`);
|
|
229
228
|
}
|
|
230
|
-
|
|
231
|
-
if (mode.slice(0, 3) === "wal") {
|
|
232
|
-
sql = "BEGIN CONCURRENT";
|
|
233
|
-
}
|
|
229
|
+
const sql = 'BEGIN TRANSACTION;';
|
|
234
230
|
db.run(sql, (err) => {
|
|
235
231
|
if (err) {
|
|
236
232
|
reject(`${msg}${err.message}`);
|
|
@@ -830,7 +826,7 @@ class UtilsSQLite {
|
|
|
830
826
|
}
|
|
831
827
|
async getJournalMode(mDB) {
|
|
832
828
|
let resQuery = [];
|
|
833
|
-
let retMode =
|
|
829
|
+
let retMode = 'delete';
|
|
834
830
|
const query = `PRAGMA journal_mode;`;
|
|
835
831
|
try {
|
|
836
832
|
resQuery = await this.queryAll(mDB, query, []);
|
|
@@ -949,8 +945,7 @@ class UtilsJson {
|
|
|
949
945
|
let changes = 0;
|
|
950
946
|
try {
|
|
951
947
|
// start a transaction
|
|
952
|
-
|
|
953
|
-
await this.sqliteUtil.beginTransaction(mDB, true, mode);
|
|
948
|
+
await this.sqliteUtil.beginTransaction(mDB, true);
|
|
954
949
|
}
|
|
955
950
|
catch (err) {
|
|
956
951
|
return Promise.reject(`CreateDatabaseSchema: ${err}`);
|
|
@@ -2586,8 +2581,7 @@ class ImportFromJson {
|
|
|
2586
2581
|
try {
|
|
2587
2582
|
initChanges = await this.sqliteUtil.dbChanges(mDB);
|
|
2588
2583
|
// start a transaction
|
|
2589
|
-
|
|
2590
|
-
await this.sqliteUtil.beginTransaction(mDB, true, mode);
|
|
2584
|
+
await this.sqliteUtil.beginTransaction(mDB, true);
|
|
2591
2585
|
}
|
|
2592
2586
|
catch (err) {
|
|
2593
2587
|
return Promise.reject(`createTablesData: ${err}`);
|
|
@@ -2647,8 +2641,7 @@ class ImportFromJson {
|
|
|
2647
2641
|
try {
|
|
2648
2642
|
initChanges = await this.sqliteUtil.dbChanges(mDB);
|
|
2649
2643
|
// start a transaction
|
|
2650
|
-
|
|
2651
|
-
await this.sqliteUtil.beginTransaction(mDB, true, mode);
|
|
2644
|
+
await this.sqliteUtil.beginTransaction(mDB, true);
|
|
2652
2645
|
}
|
|
2653
2646
|
catch (err) {
|
|
2654
2647
|
return Promise.reject(`createViews: ${err}`);
|
|
@@ -3265,9 +3258,7 @@ class UtilsUpgrade {
|
|
|
3265
3258
|
*/
|
|
3266
3259
|
async onUpgrade(mDB, vUpgDict, curVersion, targetVersion) {
|
|
3267
3260
|
let changes;
|
|
3268
|
-
const sortedKeys = Object.keys(vUpgDict)
|
|
3269
|
-
.map(item => parseInt(item))
|
|
3270
|
-
.sort();
|
|
3261
|
+
const sortedKeys = new Int32Array(Object.keys(vUpgDict).map(item => parseInt(item))).sort();
|
|
3271
3262
|
for (const versionKey of sortedKeys) {
|
|
3272
3263
|
if (versionKey > curVersion && versionKey <= targetVersion) {
|
|
3273
3264
|
const statements = vUpgDict[versionKey].statements;
|
|
@@ -3298,8 +3289,7 @@ class UtilsUpgrade {
|
|
|
3298
3289
|
*/
|
|
3299
3290
|
async executeStatementsProcess(mDB, statements) {
|
|
3300
3291
|
try {
|
|
3301
|
-
|
|
3302
|
-
await this.sqliteUtil.beginTransaction(mDB, true, mode);
|
|
3292
|
+
await this.sqliteUtil.beginTransaction(mDB, true);
|
|
3303
3293
|
for (const statement of statements) {
|
|
3304
3294
|
await this.sqliteUtil.execute(mDB, statement, false);
|
|
3305
3295
|
}
|
|
@@ -3611,7 +3601,8 @@ class Database {
|
|
|
3611
3601
|
try {
|
|
3612
3602
|
if (transaction) {
|
|
3613
3603
|
const mode = await this.sqliteUtil.getJournalMode(this.database);
|
|
3614
|
-
|
|
3604
|
+
console.log(`$$$ in executeSQL journal_mode: ${mode} $$$`);
|
|
3605
|
+
await this.sqliteUtil.beginTransaction(this.database, this._isDbOpen);
|
|
3615
3606
|
}
|
|
3616
3607
|
const changes = await this.sqliteUtil.execute(this.database, sql, false);
|
|
3617
3608
|
if (changes < 0) {
|
|
@@ -3668,7 +3659,8 @@ class Database {
|
|
|
3668
3659
|
// start a transaction
|
|
3669
3660
|
if (transaction) {
|
|
3670
3661
|
const mode = await this.sqliteUtil.getJournalMode(this.database);
|
|
3671
|
-
|
|
3662
|
+
console.log(`$$$ in runSQL journal_mode: ${mode} $$$`);
|
|
3663
|
+
await this.sqliteUtil.beginTransaction(this.database, this._isDbOpen);
|
|
3672
3664
|
}
|
|
3673
3665
|
}
|
|
3674
3666
|
catch (err) {
|
|
@@ -3712,7 +3704,8 @@ class Database {
|
|
|
3712
3704
|
// start a transaction
|
|
3713
3705
|
if (transaction) {
|
|
3714
3706
|
const mode = await this.sqliteUtil.getJournalMode(this.database);
|
|
3715
|
-
|
|
3707
|
+
console.log(`$$$ in execSet journal_mode: ${mode} $$$`);
|
|
3708
|
+
await this.sqliteUtil.beginTransaction(this.database, this._isDbOpen);
|
|
3716
3709
|
}
|
|
3717
3710
|
}
|
|
3718
3711
|
catch (err) {
|