Skip to content
Browse files

Freeze columns only once per Result

Conflicts:
	activerecord/lib/active_record/result.rb
  • Loading branch information...
1 parent 2e2f8c0 commit d2b9862b247693af16ad00e56d4510ef460bcea7 @spastorino spastorino committed with tenderlove Sep 20, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 activerecord/lib/active_record/result.rb
View
12 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 d2b9862

Please sign in to comment.
Something went wrong with that request. Please try again.