@capacitor-community/sqlite 5.7.3-3 → 5.7.3
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 +26 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ExportToJson.java +4 -2
- package/electron/dist/plugin.js +46 -39
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/ImportExportJson/ExportToJson.swift +6 -4
- package/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift +7 -9
- package/ios/Plugin/Utils/UtilsFile.swift +5 -8
- package/package.json +2 -2
|
@@ -867,18 +867,20 @@ class ExportToJson {
|
|
|
867
867
|
with: ",")
|
|
868
868
|
.replacingOccurrences(of: ", ",
|
|
869
869
|
with: ",")
|
|
870
|
-
case "PRIMARY":
|
|
870
|
+
case "PRIMARY", "UNIQUE":
|
|
871
|
+
let prefix = (String(row[0]).uppercased() == "PRIMARY") ? "CPK_" : "CUN_"
|
|
872
|
+
|
|
871
873
|
guard let oPar = rstr.firstIndex(of: "(")
|
|
872
874
|
else {
|
|
873
875
|
var msg: String = "Create Schema "
|
|
874
|
-
msg.append("PRIMARY KEY no '('")
|
|
876
|
+
msg.append("PRIMARY/UNIQUE KEY no '('")
|
|
875
877
|
throw ExportToJsonError
|
|
876
878
|
.createSchema(message: msg)
|
|
877
879
|
}
|
|
878
880
|
guard let cPar = rstr.firstIndex(of: ")")
|
|
879
881
|
else {
|
|
880
882
|
var msg: String = "Create Schema "
|
|
881
|
-
msg.append("PRIMARY KEY no ')'")
|
|
883
|
+
msg.append("PRIMARY/UNIQUE KEY no ')'")
|
|
882
884
|
throw ExportToJsonError
|
|
883
885
|
.createSchema(message: msg)
|
|
884
886
|
}
|
|
@@ -886,7 +888,7 @@ class ExportToJson {
|
|
|
886
888
|
after: oPar)..<cPar]
|
|
887
889
|
row[1] = rstr[rstr.index(rstr.startIndex,
|
|
888
890
|
offsetBy: 0)..<rstr.endIndex]
|
|
889
|
-
columns["constraint"] =
|
|
891
|
+
columns["constraint"] = prefix + String(row[0])
|
|
890
892
|
.replacingOccurrences(of: "§",
|
|
891
893
|
with: "_")
|
|
892
894
|
.replacingOccurrences(of: "_ ",
|
|
@@ -158,17 +158,14 @@ class UtilsDownloadFromHTTP {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
class func extractDBFiles(from zipFile: URL, completion: @escaping ([URL], Error?) -> Void) {
|
|
161
|
-
DispatchQueue.global().async
|
|
161
|
+
DispatchQueue.global().async {
|
|
162
162
|
var dbFiles: [URL] = []
|
|
163
163
|
|
|
164
164
|
do {
|
|
165
165
|
let destinationURL = zipFile.deletingLastPathComponent()
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
completion([], UtilsDownloadError.invalidArchive(message: msg))
|
|
170
|
-
return
|
|
171
|
-
}
|
|
167
|
+
// Use the throwing initializer
|
|
168
|
+
let archive = try Archive(url: zipFile, accessMode: .read)
|
|
172
169
|
|
|
173
170
|
for entry in archive where entry.type == .file {
|
|
174
171
|
let fileURL = destinationURL.appendingPathComponent(entry.path)
|
|
@@ -179,14 +176,15 @@ class UtilsDownloadFromHTTP {
|
|
|
179
176
|
dbFiles.append(fileURL)
|
|
180
177
|
}
|
|
181
178
|
}
|
|
179
|
+
|
|
182
180
|
// Delete the zip file
|
|
183
181
|
try FileManager.default.removeItem(at: zipFile)
|
|
184
182
|
|
|
185
183
|
completion(dbFiles, nil)
|
|
186
184
|
} catch {
|
|
187
|
-
|
|
185
|
+
let msg = "Failed in reading Archive: \(error.localizedDescription)"
|
|
186
|
+
completion([], UtilsDownloadError.invalidArchive(message: msg))
|
|
188
187
|
}
|
|
189
|
-
}
|
|
190
|
-
|
|
188
|
+
}
|
|
191
189
|
}
|
|
192
190
|
}
|
|
@@ -421,15 +421,13 @@ class UtilsFile {
|
|
|
421
421
|
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
-
class func unzipToDatabase(fromURL: URL, databaseLocation: String, zip: String,
|
|
425
|
-
overwrite: Bool) throws {
|
|
424
|
+
class func unzipToDatabase(fromURL: URL, databaseLocation: String, zip: String, overwrite: Bool) throws {
|
|
426
425
|
do {
|
|
427
426
|
let zipAsset: URL = fromURL.appendingPathComponent(zip)
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
427
|
+
|
|
428
|
+
// Use the throwing initializer
|
|
429
|
+
let archive = try Archive(url: zipAsset, accessMode: .read)
|
|
430
|
+
|
|
433
431
|
let uDb: URL = try getFolderURL(folderPath: databaseLocation)
|
|
434
432
|
for entry in archive {
|
|
435
433
|
let dbEntry = setPathSuffix(sDb: entry.path)
|
|
@@ -442,7 +440,6 @@ class UtilsFile {
|
|
|
442
440
|
}
|
|
443
441
|
_ = try archive.extract(entry, to: zipCopy)
|
|
444
442
|
}
|
|
445
|
-
|
|
446
443
|
} catch {
|
|
447
444
|
let msg = "Error: Extracting \(entry.path) from archive failed \(error.localizedDescription)"
|
|
448
445
|
print("\(msg)")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "5.7.3
|
|
3
|
+
"version": "5.7.3",
|
|
4
4
|
"description": "Community plugin for native & electron SQLite databases",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -97,6 +97,6 @@
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"jeep-sqlite": "^2.7.
|
|
100
|
+
"jeep-sqlite": "^2.7.2"
|
|
101
101
|
}
|
|
102
102
|
}
|