diff --git a/lib/database_rewinder/multiple_statements_executor.rb b/lib/database_rewinder/multiple_statements_executor.rb index b6050f4..8dbc6d2 100644 --- a/lib/database_rewinder/multiple_statements_executor.rb +++ b/lib/database_rewinder/multiple_statements_executor.rb @@ -25,6 +25,13 @@ def execute_multiple(sql) else query_options = raw_connection_or_connection.query_options.dup query_options[:connect_flags] |= Mysql2::Client::MULTI_STATEMENTS + + db_config = ActiveRecord::Base.connection_db_config.configuration_hash + query_options[:host] = db_config[:host] if db_config[:host] + query_options[:username] = db_config[:username] if db_config[:username] + query_options[:password] = db_config[:password] if db_config[:password] + query_options[:database] = db_config[:database] if db_config[:database] + # opens another connection to the DB client = Mysql2::Client.new query_options begin