From 5bed6494d49506223dc3b6652858c21487776a02 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 22 Apr 2011 15:35:54 -0500 Subject: split indexes and column types on money / binary iteration --- .../active_record/connection_adapters/postgresql_adapter.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 8763074121..fbfccd4ec1 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -473,21 +473,20 @@ module ActiveRecord } typehash = ftypes.group_by { |_, type| type } - binaries = (typehash[BYTEA_COLUMN_TYPE_OID] || []).map { |x| x.first } - monies = (typehash[MONEY_COLUMN_TYPE_OID] || []).map { |x| x.first } + binaries = typehash[BYTEA_COLUMN_TYPE_OID] || [] + monies = typehash[MONEY_COLUMN_TYPE_OID] || [] rows.each do |row| # unescape string passed BYTEA field (OID == 17) - binaries.each do |index| - data = row[index] - row[index] = unescape_bytea(data) + binaries.each do |index, _| + row[index] = unescape_bytea(row[index]) end # 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 # PostgreSQLColumn.string_to_decimal but would break form input # fields that call value_before_type_cast. - monies.each do |index| + monies.each do |index, _| data = row[index] # Because money output is formatted according to the locale, there are two # cases to consider (note the decimal separators): -- cgit v1.2.3