Skip to content

Commit

Permalink
BLOB binding issue in iOS #514
Browse files Browse the repository at this point in the history
  • Loading branch information
jepiqueau committed Feb 25, 2024
1 parent 570cb3b commit 228151f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Binary file modified android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
25 changes: 25 additions & 0 deletions ios/Plugin/Utils/UtilsBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 228151f

Please sign in to comment.