diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/tasks/mysql_database_tasks.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb index 7abbf08571..3d27c97254 100644 --- a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb @@ -73,13 +73,16 @@ module ActiveRecord configuration.merge('database' => nil) end - # If neither encoding nor collation is specified, use the utf-8 defaults. def creation_options - options = configuration.slice('encoding', 'collation').symbolize_keys - if options.empty? - { charset: DEFAULT_CHARSET, collation: DEFAULT_COLLATION } - else - options + Hash.new.tap do |options| + options[:charset] = configuration['encoding'] if configuration.include? 'encoding' + options[:collation] = configuration['collation'] if configuration.include? 'collation' + + # Set default charset only when collation isn't set. + options[:charset] ||= DEFAULT_CHARSET unless options[:collation] + + # Set default collation only when charset is also default. + options[:collation] ||= DEFAULT_COLLATION if options[:charset] == DEFAULT_CHARSET end end |