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

connection_config -> connection_db_config #17

Merged
merged 2 commits into from
Sep 13, 2021

Conversation

quentindemetz
Copy link
Contributor

DEPRECATION WARNING: connection_config is deprecated and will be removed from Rails 6.2 (Use connection_db_config instead)

DEPRECATION WARNING: connection_config is deprecated and will be removed from Rails 6.2 (Use connection_db_config instead)
@alekseyl
Copy link
Owner

OK, I'll look for the gem version branching

@tdeo
Copy link
Contributor

tdeo commented Sep 13, 2021

Hello, I've added version branching to select either connection_config or connection_db_config

@alekseyl alekseyl merged commit ff64628 into alekseyl:master Sep 13, 2021
@alekseyl
Copy link
Owner

done

@tdeo
Copy link
Contributor

tdeo commented Sep 13, 2021

Thanks for the reactivity !

@tdeo tdeo deleted the patch-1 branch September 13, 2021 14:30
@alekseyl
Copy link
Owner

Yep, merged to appreciate your work!
Thanx for using and participating in niceql :).
Shipped connection / db_connection branching with new version 0.1.3

@jhirn
Copy link

jhirn commented Sep 21, 2021

Hello @alekseyl

Unfortunately I'm having a bug with this due to ActiveRecord::Base.try(:connection_db_config) returning a speciality object ActiveRecord::DatabaseConfigurations::HashConfig which does not respond to dig. It doesn't even respond to to_h which is kind of a bummer but rather directly has the access methods on it.

Screen Shot 2021-09-21 at 1 40 40 PM

I'm not sure what version of ActiveRecord this was introduced in, but I'm using version 6.1.4.1. I can't tell if connection_db_config has always returned this Object or not. The following suggestion works for me in my case, but I haven't had time to test against other versions of AR.

  def ar_using_pg_adapter?
      return false unless defined?(::ActiveRecord::Base)
      binding.pry
      config = ActiveRecord::Base.try(:connection_db_config) || ActiveRecord::Base.try(:connection_config)
      (config.try(:adapter) || config&.dig('adapter')) == 'postgresql'
  end

It's just to avoid deprecation warning for now so not urgent. If you'd like I can put together a PR for youu

alekseyl added a commit that referenced this pull request Sep 22, 2021
* Fix to issue #17 (comment). ActiveRecord base config is no longer a hash,
so it does not have dig method, hence it's breaking the ar_using_pg_adapter? method.
* active_record added as development dependency :( for proper testing cover.
@alekseyl
Copy link
Owner

fixed in version 0.2.0!

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.

4 participants