Skip to content

Commit

Permalink
Fixed error with MySQL and binary data - #466
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Mar 19, 2024
1 parent 233ee49 commit 7bca5a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 3.0.4 (unreleased)

- Fixed error with MySQL and binary data

## 3.0.3 (2024-01-10)

- Fixed error with Trilogy, non-ASCII column names, and charts
Expand Down
14 changes: 14 additions & 0 deletions lib/blazer/adapters/sql_adapter.rb
Expand Up @@ -46,6 +46,20 @@ def run_statement(statement, comment, bind_params = [])
if adapter_name == "Trilogy"
columns.map! { |k| k.dup.force_encoding(Encoding::UTF_8) }
end

# fix for binary data
if mysql?
rows =
rows.map do |row|
row.map do |v|
if v.is_a?(String) && v.encoding == Encoding::BINARY
"0x#{v.unpack1("H*").upcase}"
else
v
end
end
end
end
rescue => e
error = e.message.sub(/.+ERROR: /, "")
error = Blazer::TIMEOUT_MESSAGE if Blazer::TIMEOUT_ERRORS.any? { |e| error.include?(e) }
Expand Down

0 comments on commit 7bca5a9

Please sign in to comment.