@capacitor-community/sqlite 5.5.2 → 5.6.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 +2 -0
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +216 -219
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ExportToJson.java +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +103 -102
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsFile.java +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsMigrate.java +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLStatement.java +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js.map +1 -1
- package/electron/dist/plugin.js +12 -6
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorSQLite.swift +3 -4
- package/ios/Plugin/Utils/UtilsDelete.swift +1 -1
- package/ios/Plugin/Utils/UtilsSQLCipher.swift +1 -2
- package/ios/Plugin/Utils/UtilsSQLStatement.swift +35 -37
- package/package.json +6 -6
- package/src/definitions.ts +0 -1
- package/src/web.ts +5 -1
|
@@ -1012,7 +1012,6 @@ enum CapacitorSQLiteError: Error {
|
|
|
1012
1012
|
|
|
1013
1013
|
// MARK: - deleteDatabase
|
|
1014
1014
|
|
|
1015
|
-
// swiftlint:disable function_body_length
|
|
1016
1015
|
// swiftlint:disable cyclomatic_complexity
|
|
1017
1016
|
@objc func deleteDatabase(_ dbName: String, readonly: Bool) throws {
|
|
1018
1017
|
guard isInit else {
|
|
@@ -1032,8 +1031,9 @@ enum CapacitorSQLiteError: Error {
|
|
|
1032
1031
|
if !mDb.isDBOpen() {
|
|
1033
1032
|
// check the state of the DB
|
|
1034
1033
|
let state: State = UtilsSQLCipher.getDatabaseState(databaseLocation: databaseLocation, databaseName: "\(mDbName)SQLite.db", account: account)
|
|
1035
|
-
if !isEncryption &&
|
|
1036
|
-
|
|
1034
|
+
if !isEncryption &&
|
|
1035
|
+
(state.rawValue == "ENCRYPTEDGLOBALSECRET" ||
|
|
1036
|
+
state.rawValue == "ENCRYPTEDSECRET") {
|
|
1037
1037
|
var msg = "Cannot delete an Encrypted database with "
|
|
1038
1038
|
msg += "No Encryption set in capacitor.config"
|
|
1039
1039
|
throw CapacitorSQLiteError.failed(message: msg)
|
|
@@ -1067,7 +1067,6 @@ enum CapacitorSQLiteError: Error {
|
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
1069
|
// swiftlint:enable cyclomatic_complexity
|
|
1070
|
-
// swiftlint:enable function_body_length
|
|
1071
1070
|
|
|
1072
1071
|
// MARK: - isJsonValid
|
|
1073
1072
|
|
|
@@ -290,7 +290,7 @@ class UtilsDelete {
|
|
|
290
290
|
var relatedItems: [[String: Any]] = []
|
|
291
291
|
var key: String = ""
|
|
292
292
|
let t1Names = withRefsNames.map { "t1.\($0)" }
|
|
293
|
-
let t2Names = colNames.map{ "t2.\($0)" }
|
|
293
|
+
let t2Names = colNames.map { "t2.\($0)" }
|
|
294
294
|
|
|
295
295
|
do {
|
|
296
296
|
var whereClause = try UtilsSQLStatement
|
|
@@ -447,7 +447,7 @@ class UtilsSQLCipher {
|
|
|
447
447
|
msg.append("Database not opened")
|
|
448
448
|
throw UtilsSQLCipherError.prepareSQL(message: msg)
|
|
449
449
|
}
|
|
450
|
-
// let systemVersion = UIDevice.current.systemVersion
|
|
450
|
+
// let systemVersion = UIDevice.current.systemVersion
|
|
451
451
|
var runSQLStatement: OpaquePointer?
|
|
452
452
|
var message: String = ""
|
|
453
453
|
var lastId: Int64 = -1
|
|
@@ -554,7 +554,6 @@ class UtilsSQLCipher {
|
|
|
554
554
|
return (lastId, result)
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
-
|
|
558
557
|
|
|
559
558
|
// MARK: - returningWorkAround
|
|
560
559
|
|
|
@@ -327,51 +327,49 @@ class UtilsSQLStatement {
|
|
|
327
327
|
|
|
328
328
|
class func isReturning(sqlStmt: String) -> (Bool, String, String) {
|
|
329
329
|
var stmt = sqlStmt.replacingOccurrences(of: "\n", with: "")
|
|
330
|
-
|
|
330
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
331
331
|
if stmt.hasSuffix(";") {
|
|
332
332
|
// Remove the suffix
|
|
333
333
|
stmt = String(stmt.dropLast())
|
|
334
|
-
|
|
334
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
switch
|
|
338
|
-
|
|
339
|
-
|
|
337
|
+
switch stmt.prefix(6).uppercased() {
|
|
338
|
+
|
|
339
|
+
case "INSERT":
|
|
340
340
|
if let valuesIndex = stmt.range(of: "VALUES", options: .caseInsensitive)?.lowerBound,
|
|
341
341
|
let closingParenthesisIndex = stmt.range(of: ")", options: .backwards, range: valuesIndex..<stmt.endIndex)?.upperBound {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
guard closingParenthesisIndex < stmt.endIndex else {
|
|
343
|
+
stmt += ";"
|
|
344
|
+
return (false, stmt, "")
|
|
345
|
+
}
|
|
346
346
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
347
|
+
let intParenthesisValue = stmt.distance(from: stmt.startIndex, to: closingParenthesisIndex)
|
|
348
|
+
let substringAfterValues = stmt[closingParenthesisIndex...]
|
|
349
|
+
var resultString = String(substringAfterValues)
|
|
350
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
351
|
+
if resultString.count > 0 && !resultString.hasSuffix(";") {
|
|
352
|
+
resultString += ";"
|
|
353
|
+
}
|
|
354
354
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
355
|
+
let substringStartToEndParenthesis = stmt[...closingParenthesisIndex]
|
|
356
|
+
let stmtString = String(substringStartToEndParenthesis)
|
|
357
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
358
|
+
.appending(";")
|
|
359
359
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
360
|
+
if substringAfterValues.lowercased().contains("returning") {
|
|
361
|
+
return (true, stmtString, resultString)
|
|
362
|
+
} else {
|
|
363
|
+
return (false, stmt, "")
|
|
365
364
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
365
|
+
}
|
|
366
|
+
return (false, stmt, "")
|
|
367
|
+
|
|
368
|
+
case "DELETE", "UPDATE":
|
|
370
369
|
let words = stmt.components(separatedBy: .whitespacesAndNewlines)
|
|
371
370
|
var wordsBeforeReturning: [String] = []
|
|
372
371
|
var returningString: [String] = []
|
|
373
372
|
|
|
374
|
-
|
|
375
373
|
var isReturningOutsideMessage = false
|
|
376
374
|
for word in words {
|
|
377
375
|
if word.lowercased() == "returning" {
|
|
@@ -387,7 +385,7 @@ class UtilsSQLStatement {
|
|
|
387
385
|
let joinedWords = wordsBeforeReturning.joined(separator: " ") + ";"
|
|
388
386
|
var joinedReturningString = returningString.joined(separator: " ")
|
|
389
387
|
if joinedReturningString.count > 0 &&
|
|
390
|
-
|
|
388
|
+
!joinedReturningString.hasSuffix(";") {
|
|
391
389
|
joinedReturningString += ";"
|
|
392
390
|
}
|
|
393
391
|
|
|
@@ -395,11 +393,11 @@ class UtilsSQLStatement {
|
|
|
395
393
|
} else {
|
|
396
394
|
return (false, stmt, "")
|
|
397
395
|
}
|
|
398
|
-
|
|
399
|
-
|
|
396
|
+
|
|
397
|
+
default:
|
|
400
398
|
return (false, stmt, "")
|
|
401
399
|
}
|
|
402
|
-
|
|
400
|
+
|
|
403
401
|
}
|
|
404
402
|
|
|
405
403
|
// MARK: - wordsAfter
|
|
@@ -410,13 +408,13 @@ class UtilsSQLStatement {
|
|
|
410
408
|
}
|
|
411
409
|
return Array(words.suffix(from: index + 1))
|
|
412
410
|
}
|
|
413
|
-
|
|
411
|
+
|
|
414
412
|
// MARK: - getStmtAndRetColNames
|
|
415
413
|
|
|
416
414
|
class func getStmtAndRetColNames(sqlStmt: String, retMode: String)
|
|
417
415
|
-> [String: String] {
|
|
418
416
|
var retStmtNames: [String: String] = [:]
|
|
419
|
-
|
|
417
|
+
|
|
420
418
|
let (isReturning, stmt, suffix) = isReturning(sqlStmt: sqlStmt)
|
|
421
419
|
retStmtNames["stmt"] = stmt
|
|
422
420
|
retStmtNames["names"] = ""
|
|
@@ -426,7 +424,7 @@ class UtilsSQLStatement {
|
|
|
426
424
|
let substring = suffix[returningIndex.upperBound...]
|
|
427
425
|
|
|
428
426
|
let names =
|
|
429
|
-
|
|
427
|
+
"\(substring)".trimmingLeadingAndTrailingSpaces()
|
|
430
428
|
if names.suffix(1) == ";" {
|
|
431
429
|
retStmtNames["names"] = String(names.dropLast())
|
|
432
430
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.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",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@capacitor/android": "^5.
|
|
63
|
-
"@capacitor/cli": "^5.
|
|
64
|
-
"@capacitor/core": "^5.
|
|
62
|
+
"@capacitor/android": "^5.6.0",
|
|
63
|
+
"@capacitor/cli": "^5.6.0",
|
|
64
|
+
"@capacitor/core": "^5.6.0",
|
|
65
65
|
"@capacitor/docgen": "^0.0.17",
|
|
66
|
-
"@capacitor/ios": "^5.
|
|
66
|
+
"@capacitor/ios": "^5.6.0",
|
|
67
67
|
"@ionic/eslint-config": "^0.3.0",
|
|
68
68
|
"@ionic/prettier-config": "^1.0.1",
|
|
69
69
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
@@ -97,6 +97,6 @@
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"jeep-sqlite": "^2.5.
|
|
100
|
+
"jeep-sqlite": "^2.5.10"
|
|
101
101
|
}
|
|
102
102
|
}
|
package/src/definitions.ts
CHANGED
package/src/web.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { WebPlugin } from '@capacitor/core';
|
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
CapacitorSQLitePlugin,
|
|
5
|
+
capConnectionOptions,
|
|
5
6
|
capAllConnectionsOptions,
|
|
6
7
|
capChangeSecretOptions,
|
|
7
8
|
capEchoOptions,
|
|
@@ -131,7 +132,7 @@ export class CapacitorSQLiteWeb
|
|
|
131
132
|
return echoResult;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
async createConnection(options:
|
|
135
|
+
async createConnection(options: capConnectionOptions): Promise<void> {
|
|
135
136
|
this.ensureJeepSqliteIsAvailable();
|
|
136
137
|
this.ensureWebstoreIsOpen();
|
|
137
138
|
|
|
@@ -204,6 +205,7 @@ export class CapacitorSQLiteWeb
|
|
|
204
205
|
} catch (err) {
|
|
205
206
|
throw new Error(`${err}`);
|
|
206
207
|
}
|
|
208
|
+
|
|
207
209
|
}
|
|
208
210
|
async beginTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges> {
|
|
209
211
|
this.ensureJeepSqliteIsAvailable();
|
|
@@ -284,6 +286,7 @@ export class CapacitorSQLiteWeb
|
|
|
284
286
|
} catch (err) {
|
|
285
287
|
throw new Error(`${err}`);
|
|
286
288
|
}
|
|
289
|
+
|
|
287
290
|
}
|
|
288
291
|
|
|
289
292
|
async executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges> {
|
|
@@ -553,6 +556,7 @@ export class CapacitorSQLiteWeb
|
|
|
553
556
|
}
|
|
554
557
|
}
|
|
555
558
|
|
|
559
|
+
|
|
556
560
|
////////////////////////////////////
|
|
557
561
|
////// UNIMPLEMENTED METHODS
|
|
558
562
|
////////////////////////////////////
|