aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-12 17:58:48 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-12 17:58:48 -0700
commit2aed63eb526b5493df63151e2bf451d55114c49a (patch)
tree70d4f4b80f5d6ee04ff2dfd7900796c117727a46 /activerecord/lib/active_record/connection_adapters
parent2c3aab32dd064c2812088c1226562ee522d55d48 (diff)
downloadrails-2aed63eb526b5493df63151e2bf451d55114c49a.tar.gz
rails-2aed63eb526b5493df63151e2bf451d55114c49a.tar.bz2
rails-2aed63eb526b5493df63151e2bf451d55114c49a.zip
our method is modifying the original array, so refactor to use destructive methods
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 87ae23d104..dd623def2e 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -950,7 +950,7 @@ module ActiveRecord
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
@@ -963,16 +963,15 @@ module ActiveRecord
# (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.