Skip to content

Commit 7bca5a9

Browse files
committed
Fixed error with MySQL and binary data - #466
1 parent 233ee49 commit 7bca5a9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.0.4 (unreleased)
2+
3+
- Fixed error with MySQL and binary data
4+
15
## 3.0.3 (2024-01-10)
26

37
- Fixed error with Trilogy, non-ASCII column names, and charts

lib/blazer/adapters/sql_adapter.rb

+14
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ def run_statement(statement, comment, bind_params = [])
4646
if adapter_name == "Trilogy"
4747
columns.map! { |k| k.dup.force_encoding(Encoding::UTF_8) }
4848
end
49+
50+
# fix for binary data
51+
if mysql?
52+
rows =
53+
rows.map do |row|
54+
row.map do |v|
55+
if v.is_a?(String) && v.encoding == Encoding::BINARY
56+
"0x#{v.unpack1("H*").upcase}"
57+
else
58+
v
59+
end
60+
end
61+
end
62+
end
4963
rescue => e
5064
error = e.message.sub(/.+ERROR: /, "")
5165
error = Blazer::TIMEOUT_MESSAGE if Blazer::TIMEOUT_ERRORS.any? { |e| error.include?(e) }

0 commit comments

Comments
 (0)