amatsuda / database_rewinder

minimalist's tiny and ultra-fast database cleaner
MIT License
806 stars 92 forks source link

Incompatible with multiverse gem after upgrading to v0.9.6 (assumption) #80

Open DmytroStepaniuk opened 3 years ago

DmytroStepaniuk commented 3 years ago

In my model there was statement like:

establish_connection "my_connection_#{ Rails.env }"

In this case there was used multiverse gem to configure 2nd DB in rails 4 project

after upgrading to v0.9.6 now it fails because of

NameError:
  undefined method `execute' for class `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
gems/database_rewinder-0.9.6/lib/database_rewinder/active_record_monkey.rb:39:in `instance_method'
gems/database_rewinder-0.9.6/lib/database_rewinder/active_record_monkey.rb:39:in `prepended'
gems/database_rewinder-0.9.6/lib/database_rewinder/active_record_monkey.rb:66:in `prepend'
gems/database_rewinder-0.9.6/lib/database_rewinder/active_record_monkey.rb:66:in `inherited'
gems/activerecord-xxxx/lib/active_record/connection_adapters/postgresql_adapter.rb:76:in `<module:ConnectionAdapters>'
gems/activerecord-xxxx/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `<module:ActiveRecord>'
gems/activerecord-xxxx/lib/active_record/connection_adapters/postgresql_adapter.rb:21:in `<top (required)>'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:274:in `require'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:274:in `block in require'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:240:in `load_dependency'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:274:in `require'
gems/activerecord-xxxx/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
gems/activerecord-xxxx/lib/active_record/connection_handling.rb:50:in `establish_connection'
my_record.rb:3:in `<class:MyRecord>'
my_record.rb:1:in `<top (required)>'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:274:in `require'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:274:in `block in require'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:240:in `load_dependency'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:274:in `require'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:360:in `require_or_load'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:494:in `load_missing_constant'
gems/activesupport-xxxx/lib/active_support/dependencies.rb:184:in `const_missing'

Just saw that there were some changes around that in the gem. I hope it can help with debugging issues like that 🤔

amatsuda commented 3 years ago

@DmytroStepaniuk Hi, thanks for reporting the error! Which exact version of Rails are you using? I tried a little bit, but I couldn't reproduce the error neigher on CI nor on my local vanilla 4.2 app.

DmytroStepaniuk commented 3 years ago

Its Rails 4.2.11.3. I guess its not just vanilla - its along with multiverse gem 🤔 For me its failing only in models that are using multiverse connection.

amatsuda commented 3 years ago

@DmytroStepaniuk Tried on Rails 4.2.11.3 + PostgreSQL + multiverse 0.2.2 + rspec-rails 3.9.1, and still not being able to reproduce. I suspect you might be bundling some kind of harmful AR monkey-patch besides database_rewinder and multiverse...

Could you now please provide a reproducible example app? A newly created Rails app on a GH public repo is preferable.