diff --git a/CHANGELOG.md b/CHANGELOG.md index d3891048..704757a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 5.6.1-2 (2024-02-25) + +### Bug Fixes + + - BLOB binding issue in iOS #514 + # 5.6.1-1 (2024-02-22) ### Remove Features diff --git a/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 2c532404..29706ea4 100644 Binary files a/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/ios/Plugin/Utils/UtilsBinding.swift b/ios/Plugin/Utils/UtilsBinding.swift index f4ee6ca4..1d9bf1d2 100644 --- a/ios/Plugin/Utils/UtilsBinding.swift +++ b/ios/Plugin/Utils/UtilsBinding.swift @@ -69,10 +69,35 @@ class UtilsBinding { let data: Data = Data(value) sqlite3_bind_blob(handle, Int32(idx), data.bytes, Int32(data.bytes.count), SQLITETRANSIENT) + } else if let value = value { + let isDict = checkTypeDict(from: value) + if isDict { + + let sortedValues = extractSortedValues(from: value as! [String : Int]) + let data: Data = Data(sortedValues) + sqlite3_bind_blob(handle, Int32(idx), data.bytes, + Int32(data.bytes.count), SQLITETRANSIENT) + } + } else { throw UtilsSQLCipherError.bindFailed } } // swiftlint:enable cyclomatic_complexity + class func extractSortedValues(from queryValues: [String: Int]) -> [UInt8] { + // Extract keys and sort them + let sortedKeys = queryValues.keys.sorted { $0.localizedStandardCompare($1) == .orderedAscending } + + // Extract corresponding values and sort them based on keys + let sortedValues = sortedKeys.compactMap { UInt8(queryValues[$0] ?? 0) } + + return sortedValues + } + class func checkTypeDict(from value: Any) -> Bool { + guard value is [String: Int] else { + return false + } + return true + } }