Skip to content

Conversation

@KeiSAKATA
Copy link

@KeiSAKATA KeiSAKATA commented Dec 14, 2025

Fix #96

mysql2 v0.5.7 removed :password from raw_connection.query_options, so this PR now derives connection parameters from ActiveRecord::Base.connection_db_config.configuration_hash (host/username/password/database) instead of query_options.

before

When I use database_rewinder with mysql2 v0.5.7.

$ bundle exec rspec spec/models/user_spec.rb

An error occurred in a `before(:suite)` hook.
Failure/Error: DatabaseRewinder.clean_with :truncation, except: %w[configurations containers server_clusters]

Mysql2::Error::ConnectionError:
  Access denied for user 'root'@'192.168.65.1' (using password: NO)
# ./spec/app_spec_helper.rb:12:in 'block (2 levels) in <main>'


Finished in 0.04335 seconds (files took 10.57 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

This PR

$ bundle exec rspec spec/models/user_spec.rb
..................

Finished in 2.25 seconds (files took 1.45 seconds to load)
18 examples, 0 failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In the mysql2 gem version 0.5.7, the password in query_options becomes empty, preventing DatabaseRewinder.clean_all from connecting.

1 participant