@capacitor-community/sqlite 4.1.0-8 → 4.1.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/README.md +1 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +7 -2
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +34 -2
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +5 -5
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsUpgrade.java +2 -1
- package/dist/esm/definitions.d.ts +33 -0
- package/dist/esm/definitions.js +21 -2
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -1
- package/dist/esm/web.js +12 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +33 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +33 -2
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +155 -51
- package/electron/dist/plugin.js.map +1 -1
- package/electron/rollup.config.js +1 -0
- package/ios/Plugin/CapacitorSQLite.swift +16 -8
- package/ios/Plugin/CapacitorSQLitePlugin.m +1 -0
- package/ios/Plugin/CapacitorSQLitePlugin.swift +27 -2
- package/ios/Plugin/Utils/UtilsUpgrade.swift +3 -1
- package/package.json +2 -2
|
@@ -482,30 +482,38 @@ enum CapacitorSQLiteError: Error {
|
|
|
482
482
|
|
|
483
483
|
// MARK: - CheckConnectionsConsistency
|
|
484
484
|
|
|
485
|
-
@objc public func checkConnectionsConsistency(_ dbNames: [String]
|
|
485
|
+
@objc public func checkConnectionsConsistency(_ dbNames: [String],
|
|
486
|
+
openModes: [String])
|
|
487
|
+
throws -> NSNumber {
|
|
486
488
|
if isInit {
|
|
487
489
|
var keys: [String] = Array(self.dbDict.keys)
|
|
490
|
+
var idx: Int = 0
|
|
491
|
+
var conns: [String] = []
|
|
492
|
+
for name in dbNames {
|
|
493
|
+
conns.append("\(openModes[idx])_\(name)")
|
|
494
|
+
idx += 1
|
|
495
|
+
}
|
|
488
496
|
do {
|
|
489
|
-
if
|
|
497
|
+
if conns.count == 0 {
|
|
490
498
|
try closeAllConnections()
|
|
491
499
|
return 0
|
|
492
500
|
}
|
|
493
|
-
if keys.count <
|
|
501
|
+
if keys.count < conns.count {
|
|
494
502
|
// not solvable inconsistency
|
|
495
503
|
try closeAllConnections()
|
|
496
504
|
return 0
|
|
497
505
|
}
|
|
498
|
-
if keys.count >
|
|
506
|
+
if keys.count > conns.count {
|
|
499
507
|
for key in keys {
|
|
500
|
-
if !
|
|
508
|
+
if !conns.contains(key) {
|
|
501
509
|
self.dbDict.removeValue(forKey: key)
|
|
502
510
|
}
|
|
503
511
|
}
|
|
504
512
|
}
|
|
505
513
|
keys = Array(self.dbDict.keys)
|
|
506
|
-
if keys.count ==
|
|
514
|
+
if keys.count == conns.count {
|
|
507
515
|
let set1 = Set(keys)
|
|
508
|
-
let set2 = Set(
|
|
516
|
+
let set2 = Set(conns)
|
|
509
517
|
let arr = Array(set1.symmetricDifference(set2))
|
|
510
518
|
if arr.count == 0 {
|
|
511
519
|
return 1
|
|
@@ -794,7 +802,7 @@ enum CapacitorSQLiteError: Error {
|
|
|
794
802
|
|
|
795
803
|
// MARK: - isDBOpen
|
|
796
804
|
|
|
797
|
-
|
|
805
|
+
@objc func isDBOpen(_ dbName: String, readonly: Bool) throws -> NSNumber {
|
|
798
806
|
if isInit {
|
|
799
807
|
let mDbName = CapacitorSQLite.getDatabaseName(dbName: dbName)
|
|
800
808
|
let connName: String = readonly ? "RO_\(mDbName)" : "RW_\(mDbName)"
|
|
@@ -44,4 +44,5 @@ CAP_PLUGIN(CapacitorSQLitePlugin, "CapacitorSQLite",
|
|
|
44
44
|
CAP_PLUGIN_METHOD(setEncryptionSecret, CAPPluginReturnPromise);
|
|
45
45
|
CAP_PLUGIN_METHOD(changeEncryptionSecret, CAPPluginReturnPromise);
|
|
46
46
|
CAP_PLUGIN_METHOD(clearEncryptionSecret, CAPPluginReturnPromise);
|
|
47
|
+
CAP_PLUGIN_METHOD(getFromHTTPRequest, CAPPluginReturnPromise);
|
|
47
48
|
)
|
|
@@ -346,8 +346,17 @@ public class CapacitorSQLitePlugin: CAPPlugin {
|
|
|
346
346
|
"Connection Array")
|
|
347
347
|
return
|
|
348
348
|
}
|
|
349
|
+
guard let openModes = call.options["openModes"] as? [String] else {
|
|
350
|
+
retHandler.rResult(
|
|
351
|
+
call: call,
|
|
352
|
+
message: "CheckConnectionsConsistency: Must provide a " +
|
|
353
|
+
"OpenModes Array")
|
|
354
|
+
return
|
|
355
|
+
}
|
|
349
356
|
do {
|
|
350
|
-
let res = try implementation
|
|
357
|
+
let res = try implementation?
|
|
358
|
+
.checkConnectionsConsistency(dbNames,
|
|
359
|
+
openModes: openModes)
|
|
351
360
|
var bRes: Bool = false
|
|
352
361
|
if res == 1 {
|
|
353
362
|
bRes = true
|
|
@@ -1149,7 +1158,16 @@ public class CapacitorSQLitePlugin: CAPPlugin {
|
|
|
1149
1158
|
if let upgVersionDict: [Int: [String: Any]] = try
|
|
1150
1159
|
implementation?.addUpgradeStatement(dbName,
|
|
1151
1160
|
upgrade: upgrade) {
|
|
1152
|
-
|
|
1161
|
+
if (
|
|
1162
|
+
versionUpgrades[dbName] != nil
|
|
1163
|
+
){
|
|
1164
|
+
for (versionKey, upgObj) in upgVersionDict {
|
|
1165
|
+
versionUpgrades[dbName]![versionKey] = upgObj
|
|
1166
|
+
}
|
|
1167
|
+
} else {
|
|
1168
|
+
versionUpgrades = ["\(dbName)": upgVersionDict]
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1153
1171
|
retHandler.rResult(call: call)
|
|
1154
1172
|
return
|
|
1155
1173
|
} else {
|
|
@@ -1305,6 +1323,13 @@ public class CapacitorSQLitePlugin: CAPPlugin {
|
|
|
1305
1323
|
}
|
|
1306
1324
|
|
|
1307
1325
|
}
|
|
1326
|
+
|
|
1327
|
+
// MARK: - GetFromHTTPRequest
|
|
1328
|
+
|
|
1329
|
+
@objc func getFromHTTPRequest(_ call: CAPPluginCall) {
|
|
1330
|
+
call.unimplemented("Not implemented on iOS.")
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1308
1333
|
|
|
1309
1334
|
// MARK: - Add Observers
|
|
1310
1335
|
|
|
@@ -22,10 +22,12 @@ class UtilsUpgrade {
|
|
|
22
22
|
currentVersion: Int,
|
|
23
23
|
targetVersion: Int,
|
|
24
24
|
databaseLocation: String) throws {
|
|
25
|
-
print("UtilsUpgrade.onUpgrade: \(currentVersion)
|
|
25
|
+
print("UtilsUpgrade.onUpgrade: from \(currentVersion) to \(targetVersion)")
|
|
26
26
|
|
|
27
27
|
for (versionKey, upgrade) in Array(upgDict).sorted(by: {$0.0 < $1.0}) {
|
|
28
28
|
if versionKey > currentVersion && versionKey <= targetVersion {
|
|
29
|
+
print("- UtilsUpgrade.onUpgrade toVersion: \(versionKey)")
|
|
30
|
+
|
|
29
31
|
guard let statements = upgrade["statements"] as? [String] else {
|
|
30
32
|
let msg: String = "Error: onUpgrade statements not given"
|
|
31
33
|
throw UtilsUpgradeError.onUpgradeFailed(message: msg)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Community plugin for native & electron SQLite databases",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -93,6 +93,6 @@
|
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"jeep-sqlite": "^1.5
|
|
96
|
+
"jeep-sqlite": "^1.6.5"
|
|
97
97
|
}
|
|
98
98
|
}
|