Skip to content

Commit

Permalink
fix BLOB binding issue in iOS #514
Browse files Browse the repository at this point in the history
  • Loading branch information
jepiqueau committed Feb 26, 2024
1 parent 81fc3e8 commit a6ff179
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 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-26)

### Bug Fixes

- exportToJson not working (iOS) issue#513

# 5.6.1-2 (2024-02-25)

### Bug Fixes
Expand Down
Binary file modified android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
20 changes: 15 additions & 5 deletions ios/Plugin/ImportExportJson/ExportToJson.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,9 @@ class ExportToJson {
row.append(val)
} else if values[pos][names[jpos]] is Int64 && (
INTEGERAFFINITY.contains(types[jpos].uppercased()) ||
NUMERICAFFINITY.contains(types[jpos].uppercased())) {
INTEGERAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased()) ||
NUMERICAFFINITY.contains(types[jpos].uppercased())) {
guard let val = values[pos][names[jpos]] as? Int64
else {
throw ExportToJsonError.createValues(
Expand All @@ -1206,8 +1208,8 @@ class ExportToJson {
row.append(val)
} else if values[pos][names[jpos]] is Int64 && (
REALAFFINITY.contains(types[jpos].uppercased()) ||
NUMERICAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased())) {
NUMERICAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased())) {
guard let val = values[pos][names[jpos]] as? Int64
else {
throw ExportToJsonError.createValues(
Expand All @@ -1217,18 +1219,26 @@ class ExportToJson {
} else if values[pos][names[jpos]] is Double && (
REALAFFINITY.contains(types[jpos].uppercased()) ||
NUMERICAFFINITY.contains(types[jpos]
.components(separatedBy: "(")[0].uppercased())) {
.components(separatedBy: "(")[0].uppercased())) {
guard let val = values[pos][names[jpos]] as? Double
else {
throw ExportToJsonError.createValues(
message: "Error value must be double")
}
row.append(val)
} else if values[pos][names[jpos]] is [UInt8] &&
BLOBAFFINITY.contains(types[jpos].uppercased()) {
guard let val = values[pos][names[jpos]] as? [UInt8]
else {
throw ExportToJsonError.createValues(
message: "Error value must be [UInt8]")
}
row.append(val)

} else {
throw ExportToJsonError.createValues(
message: "Error value is not (string, nsnull," +
"int64,double")
"int64,double,[UInt8]) ")
}
}
return row
Expand Down
9 changes: 3 additions & 6 deletions ios/Plugin/Utils/UtilsBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,12 @@ class UtilsBinding {
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])
if let dict = value as? [String: Int] {
let sortedValues = extractSortedValues(from: dict)
let data: Data = Data(sortedValues)
sqlite3_bind_blob(handle, Int32(idx), data.bytes,
Int32(data.bytes.count), SQLITETRANSIENT)
Int32(data.bytes.count), SQLITETRANSIENT)
}

} else {
throw UtilsSQLCipherError.bindFailed
}
Expand Down
1 change: 0 additions & 1 deletion ios/Plugin/Utils/UtilsDelete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ class UtilsDelete {

class func getCurrentTimeAsInteger() -> Int {
let currentTime = Date().timeIntervalSince1970
print(">>>> in getCurrentTimeAsInteger currentTime: \(currentTime)")
return Int(currentTime)
}

Expand Down

0 comments on commit a6ff179

Please sign in to comment.