Permalink
Browse files

Freeze columns only once per Result

Conflicts:
	activerecord/lib/active_record/result.rb
  • Loading branch information...
1 parent 5ca59b0 commit b5445247ad19ee0fb7f9a5ca31fd654cdaf6b005 @spastorino spastorino committed with tenderlove Sep 20, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 activerecord/lib/active_record/result.rb
@@ -26,9 +26,15 @@ def to_hash
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

0 comments on commit b544524

Please sign in to comment.