diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb index 8905137142..425b9b41d8 100644 --- a/activerecord/lib/active_record/result.rb +++ b/activerecord/lib/active_record/result.rb @@ -53,12 +53,15 @@ module ActiveRecord private def hash_rows - @hash_rows ||= @rows.map { |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)] - } + @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