diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2012-09-20 12:59:31 -0300 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-05 11:12:32 -0800 |
commit | b5445247ad19ee0fb7f9a5ca31fd654cdaf6b005 (patch) | |
tree | e69b5c2db1f73746a749e282f291979535ca6b59 /activerecord | |
parent | 5ca59b02d1cc80f3463eef062ced079eb1b3998c (diff) | |
download | rails-b5445247ad19ee0fb7f9a5ca31fd654cdaf6b005.tar.gz rails-b5445247ad19ee0fb7f9a5ca31fd654cdaf6b005.tar.bz2 rails-b5445247ad19ee0fb7f9a5ca31fd654cdaf6b005.zip |
Freeze columns only once per Result
Conflicts:
activerecord/lib/active_record/result.rb
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/result.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 9ceab2eabc..b8d2cd2866 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -26,9 +26,15 @@ module ActiveRecord private def hash_rows - @hash_rows ||= @rows.map { |row| - Hash[@columns.zip(row)] - } + @hash_rows ||= + begin + # We freeze the strings to prevent them getting duped when + # used as keys in ActiveRecord::Model's @attributes hash + columns = @columns.map { |c| c.dup.freeze } + @rows.map { |row| + Hash[columns.zip(row)] + } + end end end end |