mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
monkey patching Mysql::Stmt, calling free on the metadata
This commit is contained in:
parent
ee959a9ca1
commit
fe2ee4fafd
1 changed files with 9 additions and 4 deletions
|
@ -24,6 +24,12 @@ class Mysql
|
|||
end
|
||||
end
|
||||
|
||||
class Mysql
|
||||
class Stmt
|
||||
include Enumerable
|
||||
end
|
||||
end
|
||||
|
||||
module ActiveRecord
|
||||
class Base
|
||||
# Establishes a connection to the database that's used by all Active Record objects.
|
||||
|
@ -334,12 +340,11 @@ module ActiveRecord
|
|||
})
|
||||
if metadata = stmt.result_metadata
|
||||
cols = metadata.fetch_fields.map { |field| field.name }
|
||||
values = []
|
||||
stmt.each { |thing| values << thing }
|
||||
stmt.free_result
|
||||
result = ActiveRecord::Result.new(cols, values)
|
||||
metadata.free
|
||||
result = ActiveRecord::Result.new(cols, stmt.to_a)
|
||||
end
|
||||
|
||||
stmt.free_result
|
||||
stmt.close if bind_values.empty?
|
||||
|
||||
result
|
||||
|
|
Loading…
Reference in a new issue