@capacitor-community/sqlite 4.6.1-1 → 4.6.1-2
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/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java
CHANGED
|
@@ -1019,27 +1019,28 @@ public class CapacitorSQLite {
|
|
|
1019
1019
|
public Dictionary<Integer, JSONObject> addUpgradeStatement(JSArray upgrade) throws Exception {
|
|
1020
1020
|
Dictionary<Integer, JSONObject> upgDict = new Hashtable<>();
|
|
1021
1021
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1022
|
+
for (int i = 0; i < upgrade.length(); i++) {
|
|
1023
|
+
JSONObject upgObj = null;
|
|
1024
|
+
try {
|
|
1025
|
+
upgObj = (JSONObject) upgrade.get(i);
|
|
1026
|
+
if (upgObj == null || !upgObj.has("toVersion") || !upgObj.has("statements")) {
|
|
1027
|
+
String msg = "Must provide an upgrade statement";
|
|
1028
|
+
msg += " {toVersion,statement}";
|
|
1029
|
+
throw new Exception(msg);
|
|
1030
|
+
}
|
|
1031
|
+
} catch (Exception e) {
|
|
1032
|
+
String msg = "Must provide an upgrade statement " + e.getMessage();
|
|
1033
|
+
throw new Exception(msg);
|
|
1034
|
+
}
|
|
1035
|
+
try {
|
|
1036
|
+
int toVersion = upgObj.getInt("toVersion");
|
|
1037
|
+
upgDict.put(toVersion, upgObj);
|
|
1038
|
+
} catch (Exception e) {
|
|
1039
|
+
String msg = "Must provide toVersion as Integer" + e.getMessage();
|
|
1040
|
+
throw new Exception(msg);
|
|
1041
|
+
}
|
|
1042
1042
|
}
|
|
1043
|
+
return upgDict;
|
|
1043
1044
|
}
|
|
1044
1045
|
|
|
1045
1046
|
public Boolean isJsonValid(String parsingData) throws Exception {
|
package/electron/dist/plugin.js
CHANGED
|
@@ -3282,6 +3282,7 @@ class UtilsUpgrade {
|
|
|
3282
3282
|
async onUpgrade(mDB, vUpgDict, curVersion, targetVersion) {
|
|
3283
3283
|
let changes;
|
|
3284
3284
|
const sortedKeys = new Int32Array(Object.keys(vUpgDict).map(item => parseInt(item))).sort();
|
|
3285
|
+
console.log(`@@@ sortedKeys: ${sortedKeys}`);
|
|
3285
3286
|
for (const versionKey of sortedKeys) {
|
|
3286
3287
|
if (versionKey > curVersion && versionKey <= targetVersion) {
|
|
3287
3288
|
const statements = vUpgDict[versionKey].statements;
|
|
@@ -3299,6 +3300,7 @@ class UtilsUpgrade {
|
|
|
3299
3300
|
changes = (await this.sqliteUtil.dbChanges(mDB)) - initChanges;
|
|
3300
3301
|
}
|
|
3301
3302
|
catch (err) {
|
|
3303
|
+
console.log(`@@@@ onUpgrade: ${err}`);
|
|
3302
3304
|
return Promise.reject(`onUpgrade: ${err}`);
|
|
3303
3305
|
}
|
|
3304
3306
|
}
|
|
@@ -3314,6 +3316,7 @@ class UtilsUpgrade {
|
|
|
3314
3316
|
try {
|
|
3315
3317
|
await this.sqliteUtil.beginTransaction(mDB, true);
|
|
3316
3318
|
for (const statement of statements) {
|
|
3319
|
+
console.log(`@@@ statement: ${statement}`);
|
|
3317
3320
|
await this.sqliteUtil.execute(mDB, statement, false);
|
|
3318
3321
|
}
|
|
3319
3322
|
await this.sqliteUtil.commitTransaction(mDB, true);
|
|
@@ -3321,6 +3324,7 @@ class UtilsUpgrade {
|
|
|
3321
3324
|
}
|
|
3322
3325
|
catch (err) {
|
|
3323
3326
|
await this.sqliteUtil.rollbackTransaction(mDB, true);
|
|
3327
|
+
console.log(`@@@ ExecuteStatementProcess: ${err}`);
|
|
3324
3328
|
return Promise.reject(`ExecuteStatementProcess: ${err}`);
|
|
3325
3329
|
}
|
|
3326
3330
|
}
|
|
@@ -3404,6 +3408,8 @@ class Database {
|
|
|
3404
3408
|
this._isDbOpen = true;
|
|
3405
3409
|
if (!this.readonly) {
|
|
3406
3410
|
const curVersion = await this.sqliteUtil.getVersion(this.database);
|
|
3411
|
+
console.log(`@@@@ this.readonly: ${this.readonly}`);
|
|
3412
|
+
console.log(`@@@@ this.version: ${this.version} curVersion: ${curVersion}`);
|
|
3407
3413
|
if (this.version > curVersion &&
|
|
3408
3414
|
Object.keys(this.upgradeVersionDict).length > 0) {
|
|
3409
3415
|
try {
|
|
@@ -4348,23 +4354,25 @@ class CapacitorSQLite {
|
|
|
4348
4354
|
async addUpgradeStatement(options) {
|
|
4349
4355
|
const dbName = this.getOptionValue(options, 'database');
|
|
4350
4356
|
const upgrades = this.getOptionValue(options, 'upgrade');
|
|
4351
|
-
const
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4357
|
+
for (const upgrade of upgrades) {
|
|
4358
|
+
const versionUpgradeKeys = Object.keys(upgrade);
|
|
4359
|
+
if (!versionUpgradeKeys.includes('toVersion') ||
|
|
4360
|
+
!versionUpgradeKeys.includes('statements')) {
|
|
4361
|
+
throw new Error('Must provide an upgrade capSQLiteVersionUpgrade Object');
|
|
4362
|
+
}
|
|
4363
|
+
if (typeof upgrade.toVersion != 'number') {
|
|
4364
|
+
throw new Error('upgrade.toVersion must be a number');
|
|
4365
|
+
}
|
|
4366
|
+
if (this.versionUpgrades[dbName]) {
|
|
4367
|
+
this.versionUpgrades[dbName][upgrade.toVersion] = upgrade;
|
|
4368
|
+
}
|
|
4369
|
+
else {
|
|
4370
|
+
const upgradeVersionDict = {};
|
|
4371
|
+
upgradeVersionDict[upgrade.toVersion] = upgrade;
|
|
4372
|
+
this.versionUpgrades[dbName] = upgradeVersionDict;
|
|
4373
|
+
}
|
|
4367
4374
|
}
|
|
4375
|
+
console.log(`this.versionUpgrades: ${JSON.stringify(this.versionUpgrades)}`);
|
|
4368
4376
|
return;
|
|
4369
4377
|
}
|
|
4370
4378
|
async copyFromAssets(options) {
|