diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-13 17:38:34 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-26 13:44:09 -0700 |
commit | fe2ee4fafdb6b29e4dde7ba287a4c342701e1056 (patch) | |
tree | 64571f71493ff1681f72c1779b73dbcd6841bedd /activerecord | |
parent | ee959a9ca1f3eb75baa4e7dc6929cb209c610c85 (diff) | |
download | rails-fe2ee4fafdb6b29e4dde7ba287a4c342701e1056.tar.gz rails-fe2ee4fafdb6b29e4dde7ba287a4c342701e1056.tar.bz2 rails-fe2ee4fafdb6b29e4dde7ba287a4c342701e1056.zip |
monkey patching Mysql::Stmt, calling free on the metadata
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 13 |
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 |