Freeze columns just before using them as hash keys
This commit is contained in:
parent
2004ef2044
commit
2068d30091
@ -11,7 +11,7 @@ class Result
|
||||
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 @@ def initialize_copy(other)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user