From 707958b52eaf2bc58807d31c65e07c95736f6d03 Mon Sep 17 00:00:00 2001 From: Geoff Harcourt Date: Wed, 17 Sep 2014 18:58:59 -0400 Subject: 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`. --- .../active_record/connection_adapters/postgresql/schema_statements.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') 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 -- cgit v1.2.3