Closed jacobat closed 1 year ago
Same problem over here. It "works" if I remove database cleaner.
@jacobat, did you find some solution? The only way I found was to remove alias at database.yml
and duplicate all the config.
I added a monkey patch in an initializer:
if defined?(DatabaseCleaner)
module DatabaseCleaner
module ActiveRecord
class Base
private
def load_config
if db != :default && db.is_a?(Symbol) && File.file?(DatabaseCleaner::ActiveRecord.config_file_location)
connection_details = YAML::load(ERB.new(IO.read(DatabaseCleaner::ActiveRecord.config_file_location)).result, aliases: true)
@connection_hash = valid_config(connection_details, db.to_s)
end
end
end
end
end
end
Thanks, man! 🤜🤛
@jacobat Thanks for submitting this issue! Would you be interested in submitting a PR so that people no longer have to use that monkey patch?
@etagwerker I believe this is fixed on active_record
adapter on https://github.com/DatabaseCleaner/database_cleaner-active_record/blob/v2.1.0/lib/database_cleaner/active_record/base.rb#L57 but we need a new version of database-cleaner released with a loosen restriction on https://github.com/DatabaseCleaner/database_cleaner/blob/main/database_cleaner.gemspec#L19 otherwise we can't update the active-record adapter with the fix with an bundle update database_cleaner-active_record
.
This is the fix: https://github.com/DatabaseCleaner/database_cleaner-active_record/commit/b750ac73ee38dc5706dcb9a97a0061e18ab5fe06
I suggest using just ~> 2
there to easy future updates to get minor and patch fixes.
@jvortmann Sounds like a good idea. Thank you!
Thank you!
When trying to use DatabaseCleaner 2.0.0 with Ruby 3.1 and a database.yml file containing aliases I get this error:
The YAML loading in Ruby 3.1 no longer supports aliases in YAML by default.
Further information and examples: https://bugs.ruby-lang.org/issues/17866 https://github.com/rails/rails/commit/179d0a1f474ada02e0030ac3bd062fc653765dbe https://github.com/mperham/sidekiq/pull/5141