Skip to content

Commit

Permalink
Fixed error with binary data - fixes #385, closes #387
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Apr 21, 2022
1 parent 2dbbcc2 commit 011c2c8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 2.6.1 (unreleased)

- Added `region` setting to Amazon Athena
- Fixed error with binary data

## 2.6.0 (2022-04-20)

Expand Down
2 changes: 2 additions & 0 deletions lib/blazer/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def column_types
"time"
elsif v.nil?
nil
elsif v.is_a?(String) && v.encoding == Encoding::BINARY
"binary"
else
"string"
end
Expand Down
5 changes: 5 additions & 0 deletions test/adapters/mysql_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def test_quoted
end
end

def test_binary
# checks for successful response
run_statement "SELECT UNHEX('F6'), 1", format: "html"
end

private

def prepared_statements?
Expand Down
6 changes: 3 additions & 3 deletions test/support/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def assert_bad_position(statement, **params)
assert_error "Variable cannot be used in this position", statement, **params
end

def run_statement(statement, **params)
run_query statement, **params, data_source: data_source, format: "csv"
CSV.parse(response.body, headers: true).map(&:to_h)
def run_statement(statement, format: "csv", **params)
run_query statement, **params, data_source: data_source, format: format
CSV.parse(response.body, headers: true).map(&:to_h) if format == "csv"
end
end

0 comments on commit 011c2c8

Please sign in to comment.