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

Stringify database configurations #33968

Merged
merged 1 commit into from Sep 25, 2018

Conversation

@gmcgibbon
Copy link
Member

@gmcgibbon gmcgibbon commented Sep 24, 2018

Allows configurations to be assigned as symbolized hashes as in

defaults = { database: ":memory:" }
adapter = defined?(JRUBY_VERSION) ? "jdbcsqlite3" : "sqlite3"
options = defaults.merge adapter: adapter, timeout: 500
ActiveRecord::Base.establish_connection(options)
ActiveRecord::Base.configurations = { "sqlite3_ar_integration" => options }

Without this, sometimes ActiveRecord::DatabaseConfigurations can think that a configuration is a URL config when its really a hash config.

r? @eileencodes
/cc @rafaelfranca

@rails-bot
Copy link

@rails-bot rails-bot commented Sep 24, 2018

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @eileencodes (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@gmcgibbon gmcgibbon force-pushed the stringify_db_configurations branch 2 times, most recently from 37ea1e0 to 6fbd5cf Sep 24, 2018
@gmcgibbon gmcgibbon force-pushed the stringify_db_configurations branch from 6fbd5cf to 63c4e97 Sep 24, 2018
@rafaelfranca rafaelfranca merged commit eb8df3f into rails:master Sep 25, 2018
2 checks passed
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this issue Oct 5, 2018
Since rails#33968 we stringify keys of database configuration
This commit adds more assertions in order to ensure that and prevent any
regression in the future.
Currently, if remove `to_s` added in rails#33968 from `env_name.to_s` on the
line
(activerecord/lib/active_record/database_configurations.rb:107), there is
no test that would fail. One of the added assertions should emphasize why we need
this `to_s`.

Follow up rails#33968
@gmcgibbon gmcgibbon deleted the stringify_db_configurations branch Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants