aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb13
1 files changed, 9 insertions, 4 deletions
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