Skip to content

Commit

Permalink
Improved casting code
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Mar 19, 2024
1 parent bd06aab commit 3e30b67
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/blazer/adapters/sql_adapter.rb
Expand Up @@ -29,8 +29,15 @@ def run_statement(statement, comment, bind_params = [])
end

columns = result.columns
result.rows.each do |untyped_row|
rows << (result.column_types.empty? ? untyped_row : columns.each_with_index.map { |c, i| untyped_row[i] && result.column_types[c] ? result.column_types[c].send(:cast_value, untyped_row[i]) : untyped_row[i] })
rows = result.rows
if result.column_types.any?
types = columns.map { |c| result.column_types[c] }
rows =
rows.map do |row|
row.map.with_index do |v, i|
v && (t = types[i]) ? t.send(:cast_value, v) : v
end
end
end

# fix for non-ASCII column names and charts
Expand Down

0 comments on commit 3e30b67

Please sign in to comment.