diff --git a/lib/blazer/adapters/sql_adapter.rb b/lib/blazer/adapters/sql_adapter.rb index 154158b86..38c3d4414 100644 --- a/lib/blazer/adapters/sql_adapter.rb +++ b/lib/blazer/adapters/sql_adapter.rb @@ -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