@capacitor-community/sqlite 5.6.1-1 → 5.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.
|
@@ -69,10 +69,35 @@ class UtilsBinding {
|
|
|
69
69
|
let data: Data = Data(value)
|
|
70
70
|
sqlite3_bind_blob(handle, Int32(idx), data.bytes,
|
|
71
71
|
Int32(data.bytes.count), SQLITETRANSIENT)
|
|
72
|
+
} else if let value = value {
|
|
73
|
+
let isDict = checkTypeDict(from: value)
|
|
74
|
+
if isDict {
|
|
75
|
+
|
|
76
|
+
let sortedValues = extractSortedValues(from: value as! [String : Int])
|
|
77
|
+
let data: Data = Data(sortedValues)
|
|
78
|
+
sqlite3_bind_blob(handle, Int32(idx), data.bytes,
|
|
79
|
+
Int32(data.bytes.count), SQLITETRANSIENT)
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
} else {
|
|
73
83
|
throw UtilsSQLCipherError.bindFailed
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
}
|
|
77
87
|
// swiftlint:enable cyclomatic_complexity
|
|
88
|
+
class func extractSortedValues(from queryValues: [String: Int]) -> [UInt8] {
|
|
89
|
+
// Extract keys and sort them
|
|
90
|
+
let sortedKeys = queryValues.keys.sorted { $0.localizedStandardCompare($1) == .orderedAscending }
|
|
91
|
+
|
|
92
|
+
// Extract corresponding values and sort them based on keys
|
|
93
|
+
let sortedValues = sortedKeys.compactMap { UInt8(queryValues[$0] ?? 0) }
|
|
94
|
+
|
|
95
|
+
return sortedValues
|
|
96
|
+
}
|
|
97
|
+
class func checkTypeDict(from value: Any) -> Bool {
|
|
98
|
+
guard value is [String: Int] else {
|
|
99
|
+
return false
|
|
100
|
+
}
|
|
101
|
+
return true
|
|
102
|
+
}
|
|
78
103
|
}
|