aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-09-20 01:43:36 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2012-09-20 01:43:43 -0300
commit2068d300917ed95a82e7377ee77b397fc4084a61 (patch)
tree2517ab9ada7f76cc0680007d805444275b3d5a39
parent2004ef2044eae3922dbedf77a7e5f9b73a211a23 (diff)
downloadrails-2068d300917ed95a82e7377ee77b397fc4084a61.tar.gz
rails-2068d300917ed95a82e7377ee77b397fc4084a61.tar.bz2
rails-2068d300917ed95a82e7377ee77b397fc4084a61.zip
Freeze columns just before using them as hash keys
-rw-r--r--activerecord/lib/active_record/result.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb
index 5011a0d75d..8905137142 100644
--- a/activerecord/lib/active_record/result.rb
+++ b/activerecord/lib/active_record/result.rb
@@ -11,7 +11,7 @@ module ActiveRecord
attr_reader :columns, :rows, :column_types
def initialize(columns, rows, column_types = {})
- @columns = columns.map{|c| c.freeze}
+ @columns = columns
@rows = rows
@hash_rows = nil
@column_types = column_types
@@ -54,7 +54,10 @@ module ActiveRecord
private
def hash_rows
@hash_rows ||= @rows.map { |row|
- Hash[@columns.zip(row)]
+ # We freeze the strings to prevent them getting duped when
+ # used as keys in ActiveRecord::Model's @attributes hash
+ columns = @columns.map { |c| c.freeze }
+ Hash[columns.zip(row)]
}
end
end