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
Use dup'ed options hash #31641
Use dup'ed options hash #31641
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @georgeclaghorn (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. |
We want to keep diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 400f954..4176bb4 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -315,11 +315,14 @@ def gem_for_database
def convert_database_option_for_jruby
if defined?(JRUBY_VERSION)
- case options[:database]
- when "postgresql" then options[:database].replace "jdbcpostgresql"
- when "mysql" then options[:database].replace "jdbcmysql"
- when "sqlite3" then options[:database].replace "jdbcsqlite3"
+ opt = options.dup
+ case opt[:database]
+ when "postgresql" then opt[:database] = "jdbcpostgresql"
+ when "mysql" then opt[:database] = "jdbcmysql"
+ when "sqlite3" then opt[:database] = "jdbcsqlite3"
end
+
+ self.options = opt
end |
I don't think it even needs to duplicate options; seems that it can safely update the existing |
|
Ah, right 👍 |
I changed my PR based on @y-yagi's proposal. Only difference is, that I'm freezing the |
LGTM. Please squash your commits into a single commit? |
Otherwise, at least using JRuby, the replacements in convert_database_option_for_jruby won't work. Thus a call to bundle exec rails app:update fails. Simply replacing those replace statements doesn't seem to work either, since the options hash seems to be frozen, too.
129b9d8
to
c33f47d
Compare
@ckoenig Thanks! |
Otherwise, at least using JRuby, the replacements in
convert_database_option_for_jruby
won't work. Thus a call tofails. Simply replacing those replace statements doesn't seem to work either, since the options hash seems to be frozen, too.