From 0bdcf0c7eceab39bc4c76ccc51e06885b5e7c307 Mon Sep 17 00:00:00 2001 From: KeiSAKATA Date: Sun, 14 Dec 2025 18:00:31 +0900 Subject: [PATCH] Fix connection when mysql2 v0.5.7 --- lib/database_rewinder/multiple_statements_executor.rb | 7 +++++++ 1 file changed, 7 insertions(+) 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