diff options
author | Geoff Harcourt <geoff.harcourt@gmail.com> | 2014-09-17 18:58:59 -0400 |
---|---|---|
committer | Geoff Harcourt <geoff.harcourt@gmail.com> | 2014-09-17 18:58:59 -0400 |
commit | 707958b52eaf2bc58807d31c65e07c95736f6d03 (patch) | |
tree | 5e28c75186978b345434da1c9b37459e774498e1 | |
parent | 44033d8f428079d824d9b306af94f7ab0eb9952a (diff) | |
download | rails-707958b52eaf2bc58807d31c65e07c95736f6d03.tar.gz rails-707958b52eaf2bc58807d31c65e07c95736f6d03.tar.bz2 rails-707958b52eaf2bc58807d31c65e07c95736f6d03.zip |
Use #inject over #sum to build PG create DB statement
While investigating #16951 I found that another library's monkey-patching of
`Enumerable` was causing the test migrations helper to break when trying to
build the `CREATE DATABASE` statement. The prior approach used `#sum` to build
the string from the options hash.
As the code that combines the options to build the database statement is not
user-facing, using `#inject` here instead will remove the only place where the
database creation/migration code is dependent on ActiveSupport's monkey-patching
of `Enumerable`.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index fda5bbad5c..799aafbd99 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -60,8 +60,8 @@ module ActiveRecord def create_database(name, options = {}) options = { encoding: 'utf8' }.merge!(options.symbolize_keys) - option_string = options.sum do |key, value| - case key + option_string = options.inject("") do |memo, (key, value)| + memo += case key when :owner " OWNER = \"#{value}\"" when :template |