aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-01-29 17:45:08 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-01-29 17:46:08 +0900
commit798da629cea6094ffd0d43487991da628706a087 (patch)
treea7599143faa45d510c503229c12fda4721d140ba
parentb2c5ec234293813d16a65f73ee688a18900bf173 (diff)
downloadrails-798da629cea6094ffd0d43487991da628706a087.tar.gz
rails-798da629cea6094ffd0d43487991da628706a087.tar.bz2
rails-798da629cea6094ffd0d43487991da628706a087.zip
Extract `discard_remaining_results` for mysql2 adapter
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb6
2 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index e4f31586d8..1fb0bd8d56 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -527,10 +527,8 @@ module ActiveRecord
end
def insert_fixtures_set(fixture_set, tables_to_delete = [])
- iterate_over_results = -> { while raw_connection.next_result; end; }
-
with_multi_statements do
- super(fixture_set, tables_to_delete, &iterate_over_results)
+ super { discard_remaining_results }
end
end
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
index 148a16328f..5beaeec9c4 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
@@ -11,7 +11,7 @@ module ActiveRecord
else
super
end
- @connection.next_result while @connection.more_results?
+ discard_remaining_results
result
end
@@ -58,6 +58,10 @@ module ActiveRecord
@connection.last_id
end
+ def discard_remaining_results
+ @connection.next_result while @connection.more_results?
+ end
+
def exec_stmt_and_free(sql, name, binds, cache_stmt: false)
# make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been
# made since we established the connection