Skip to content

Commit

Permalink
our method is modifying the original array, so refactor to use destru…
Browse files Browse the repository at this point in the history
…ctive methods
  • Loading branch information
tenderlove committed Jul 13, 2010
1 parent 2c3aab3 commit 2aed63e
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -950,7 +950,7 @@ def select_raw(sql, name = nil)
res = execute(sql, name)
results = result_as_array(res)
fields = res.fields
rows = results.map do |row|
results.each do |row|
row.each_with_index do |cell, cell_index|
# If this is a money type column and there are any currency symbols,
# then strip them off. Indeed it would be prettier to do this in
Expand All @@ -963,16 +963,15 @@ def select_raw(sql, name = nil)
# (2) $12.345.678,12
case cell
when /^-?\D+[\d,]+\.\d{2}$/ # (1)
row[cell_index] = cell.gsub(/[^-\d\.]/, '')
cell.gsub!(/[^-\d\.]/, '')
when /^-?\D+[\d\.]+,\d{2}$/ # (2)
row[cell_index] = cell.gsub(/[^-\d,]/, '').sub(/,/, '.')
cell.gsub!(/[^-\d,]/, '').sub!(/,/, '.')
end
end
end
row
end
res.clear
return fields, rows
return fields, results
end

# Returns the list of a table's column names, data types, and default values.
Expand Down

0 comments on commit 2aed63e

Please sign in to comment.