@capacitor-community/sqlite 5.6.1 → 5.6.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/README.md +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +22 -6
- package/electron/dist/plugin.js +25 -33
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/Utils/UtilsSQLCipher.swift +18 -12
- package/ios/Plugin/Utils/UtilsSQLStatement.swift +31 -9
- package/package.json +2 -2
|
@@ -463,7 +463,7 @@ class UtilsSQLCipher {
|
|
|
463
463
|
retMode = "wA\(retMode)"
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
if (retMode == "no" || retMode.prefix(2) == "wA")
|
|
466
|
+
if (retMode == "no" || retMode.prefix(2) == "wA") {
|
|
467
467
|
let stmtNames = UtilsSQLStatement
|
|
468
468
|
.getStmtAndRetColNames(sqlStmt: sqlStmt,
|
|
469
469
|
retMode: retMode)
|
|
@@ -834,6 +834,12 @@ class UtilsSQLCipher {
|
|
|
834
834
|
return Int(sqlite3_total_changes(mDB))
|
|
835
835
|
}
|
|
836
836
|
|
|
837
|
+
// MARK: - dbLastId
|
|
838
|
+
|
|
839
|
+
class func dbLastId(mDB: OpaquePointer?) -> Int64 {
|
|
840
|
+
return Int64(sqlite3_last_insert_rowid(mDB))
|
|
841
|
+
}
|
|
842
|
+
|
|
837
843
|
// MARK: - Execute
|
|
838
844
|
|
|
839
845
|
// swiftlint:disable function_body_length
|
|
@@ -970,17 +976,17 @@ class UtilsSQLCipher {
|
|
|
970
976
|
}
|
|
971
977
|
}
|
|
972
978
|
} else {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
979
|
+
let resp = try UtilsSQLCipher
|
|
980
|
+
.prepareSQL(mDB: mDB, sql: sql, values: values,
|
|
981
|
+
fromJson: false, returnMode: returnMode)
|
|
982
|
+
lastId = resp.0
|
|
983
|
+
respSet = resp.1
|
|
984
|
+
if lastId == -1 {
|
|
985
|
+
let message: String = "lastId < 0"
|
|
986
|
+
throw UtilsSQLCipherError.executeSet(
|
|
987
|
+
message: message)
|
|
988
|
+
}
|
|
989
|
+
response = addToResponse(response: response, respSet: respSet)
|
|
984
990
|
}
|
|
985
991
|
}
|
|
986
992
|
|
|
@@ -326,8 +326,7 @@ class UtilsSQLStatement {
|
|
|
326
326
|
// MARK: - isReturning
|
|
327
327
|
|
|
328
328
|
class func isReturning(sqlStmt: String) -> (Bool, String, String) {
|
|
329
|
-
var stmt = sqlStmt.
|
|
330
|
-
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
329
|
+
var stmt = sqlStmt.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
331
330
|
if stmt.hasSuffix(";") {
|
|
332
331
|
// Remove the suffix
|
|
333
332
|
stmt = String(stmt.dropLast())
|
|
@@ -360,10 +359,10 @@ class UtilsSQLStatement {
|
|
|
360
359
|
if substringAfterValues.lowercased().contains("returning") {
|
|
361
360
|
return (true, stmtString, resultString)
|
|
362
361
|
} else {
|
|
363
|
-
return (false,
|
|
362
|
+
return (false, sqlStmt, "")
|
|
364
363
|
}
|
|
365
364
|
}
|
|
366
|
-
return (false,
|
|
365
|
+
return (false, sqlStmt, "")
|
|
367
366
|
|
|
368
367
|
case "DELETE", "UPDATE":
|
|
369
368
|
let words = stmt.components(separatedBy: .whitespacesAndNewlines)
|
|
@@ -391,11 +390,11 @@ class UtilsSQLStatement {
|
|
|
391
390
|
|
|
392
391
|
return (true, joinedWords, joinedReturningString)
|
|
393
392
|
} else {
|
|
394
|
-
return (false,
|
|
393
|
+
return (false, sqlStmt, "")
|
|
395
394
|
}
|
|
396
395
|
|
|
397
396
|
default:
|
|
398
|
-
return (false,
|
|
397
|
+
return (false, sqlStmt, "")
|
|
399
398
|
}
|
|
400
399
|
|
|
401
400
|
}
|
|
@@ -425,14 +424,37 @@ class UtilsSQLStatement {
|
|
|
425
424
|
|
|
426
425
|
let names =
|
|
427
426
|
"\(substring)".trimmingLeadingAndTrailingSpaces()
|
|
428
|
-
|
|
429
|
-
retStmtNames["names"] = String(names.dropLast())
|
|
430
|
-
}
|
|
427
|
+
retStmtNames["names"] = getNames(from: names)
|
|
431
428
|
}
|
|
432
429
|
}
|
|
433
430
|
return retStmtNames
|
|
434
431
|
}
|
|
435
432
|
|
|
433
|
+
// MARK: - getNames
|
|
434
|
+
|
|
435
|
+
class func getNames(from input: String) -> String {
|
|
436
|
+
// Find the index of the first occurrence of ";", "--", or "/*"
|
|
437
|
+
let indexSemicolon = input.firstIndex(of: ";")
|
|
438
|
+
let indexDoubleDash = input.range(of: "--")
|
|
439
|
+
let indexCommentStart = input.range(of: "/*")
|
|
440
|
+
|
|
441
|
+
// Find the minimum index among them
|
|
442
|
+
var minIndex = input.endIndex
|
|
443
|
+
if let index = indexSemicolon {
|
|
444
|
+
minIndex = min(minIndex, index)
|
|
445
|
+
}
|
|
446
|
+
if let index = indexDoubleDash?.lowerBound {
|
|
447
|
+
minIndex = min(minIndex, index)
|
|
448
|
+
}
|
|
449
|
+
if let index = indexCommentStart?.lowerBound {
|
|
450
|
+
minIndex = min(minIndex, index)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Extract substring up to the minimum index
|
|
454
|
+
let colnames = String(input[..<minIndex]).trimmingCharacters(in: .whitespacesAndNewlines)
|
|
455
|
+
return colnames
|
|
456
|
+
}
|
|
457
|
+
|
|
436
458
|
// MARK: - extractCombinedPrimaryKey
|
|
437
459
|
|
|
438
460
|
class func extractCombinedPrimaryKey(from whereClause: String)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.2",
|
|
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.
|
|
100
|
+
"jeep-sqlite": "^2.6.0"
|
|
101
101
|
}
|
|
102
102
|
}
|