Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActsAsTaggableOn.force_binary_collation breaks db:create #905

Open
dvmonroe opened this issue Jun 28, 2018 · 3 comments · May be fixed by #977
Open

ActsAsTaggableOn.force_binary_collation breaks db:create #905

dvmonroe opened this issue Jun 28, 2018 · 3 comments · May be fixed by #977

Comments

@dvmonroe
Copy link

dvmonroe commented Jun 28, 2018

Versions
ActsAsTaggableOn: 6.0
Rails: 5.2
Ruby: 2.4.2

Steps to reproduce

$ rails new Foobar -d mysql
$ cd Foobar && echo "ActsAsTaggableOn.force_binary_collation = true" > config/initializers/acts_as_taggable_on.rb && echo 'gem "acts-as-taggable-on"' >> Gemfile
$ bundle
$ rails db:create

Expected Behavior
Able to successfully run rails db:create.

Actual Behavior
Utils.connection is blindly expecting an AR connection leaving the end user no choice but to wrap the initializer in a conditional that rescues from ActiveRecord::NoDatabaseError.

rails aborted!
ActiveRecord::NoDatabaseError: Unknown database 'foobar_development'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/mysql2_adapter.rb:26:in `rescue in mysql2_connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/mysql2_adapter.rb:13:in `mysql2_connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:90:in `connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/acts-as-taggable-on-6.0.0/lib/acts_as_taggable_on/utils.rb:8:in `connection'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/acts-as-taggable-on-6.0.0/lib/acts_as_taggable_on/utils.rb:16:in `using_mysql?'
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/acts-as-taggable-on-6.0.0/lib/acts-as-taggable-on.rb:94:in `force_binary_collation='
/Users/plu/.rbenv/versions/2.4.2/gemsets/foobar/gems/acts-as-taggable-on-6.0.0/lib/acts-as-taggable-on.rb:50:in `method_missing'
/Users/plu/Projects/work/foobar/config/initializers/acts_as_taggable.rb:24:in `<top (required)>
@saluminati
Copy link

wasted so much of my time. any solution to this ?

@shuuuuun
Copy link

Provisionally, I've solved it this way in config/initializers/acts_as_taggable_on.rb.

begin
  ActsAsTaggableOn.force_binary_collation = true
rescue ActiveRecord::NoDatabaseError => err
  Rails.logger.error err
end

I hope that this issue will be fixed.

@tbuyle
Copy link

tbuyle commented Jan 6, 2022

Faced this issue today.

@shuuuuun workaround solved it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants