diff options
Diffstat (limited to 'activerecord/lib/active_record/tasks/mysql_database_tasks.rb')
-rw-r--r-- | activerecord/lib/active_record/tasks/mysql_database_tasks.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb index 2340f949b7..3d27c97254 100644 --- a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb @@ -74,10 +74,16 @@ module ActiveRecord end def creation_options - { - charset: (configuration['encoding'] || DEFAULT_CHARSET), - collation: (configuration['collation'] || DEFAULT_COLLATION) - } + 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 def error_class |