From fe2ee4fafdb6b29e4dde7ba287a4c342701e1056 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 13 Oct 2010 17:38:34 -0700 Subject: monkey patching Mysql::Stmt, calling free on the metadata --- .../lib/active_record/connection_adapters/mysql_adapter.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters') diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index f2e8366bb9..76d5611cd2 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -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 -- cgit v1.2.3