diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-17 10:09:49 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-17 10:09:49 +0900 |
commit | 21f0855dd6ee624429f92d0a67d5d95fa75ff9cc (patch) | |
tree | 36eaee04883871a7810c1523b8006bf4f8c11537 | |
parent | 0ad70eb2d063cab577a559f6c3d28e787ca1dca8 (diff) | |
download | rails-21f0855dd6ee624429f92d0a67d5d95fa75ff9cc.tar.gz rails-21f0855dd6ee624429f92d0a67d5d95fa75ff9cc.tar.bz2 rails-21f0855dd6ee624429f92d0a67d5d95fa75ff9cc.zip |
Ensure `execute_batch` discards remaining results
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb | 17 |
2 files changed, 5 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 0cf0290770..4fc39aed78 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -153,7 +153,6 @@ module ActiveRecord disable_referential_integrity do Array(build_truncate_statements(*table_names)).each do |sql| execute_batch(sql, "Truncate Tables") - yield if block_given? end end end @@ -394,7 +393,6 @@ module ActiveRecord transaction(requires_new: true) do total_sql.each do |sql| execute_batch(sql, "Fixtures Load") - yield if block_given? end 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 421afc34bc..2158b0091a 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb @@ -68,15 +68,12 @@ module ActiveRecord end alias :exec_update :exec_delete - def insert_fixtures_set(fixture_set, tables_to_delete = []) # :nodoc: - super { discard_remaining_results } - end - - def truncate_tables(*table_names) # :nodoc: - super { discard_remaining_results } - end - private + def execute_batch(sql, name = nil) + super + @connection.abandon_results! + end + def default_insert_value(column) Arel.sql("DEFAULT") unless column.auto_increment? end @@ -85,10 +82,6 @@ module ActiveRecord @connection.last_id end - def discard_remaining_results - @connection.abandon_results! - end - def supports_set_server_option? @connection.respond_to?(:set_server_option) end |