diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-09-21 12:03:11 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-09-21 12:03:16 -0700 |
commit | 78b30fed9336336694fb2cb5d2825f95800b541c (patch) | |
tree | b3bb786dfd966d42988b87dee9ec8c56c45a4e44 /activerecord/lib/active_record/tasks | |
parent | 68bd4db190fea5aad213886898e3d541f8de6fa5 (diff) | |
download | rails-78b30fed9336336694fb2cb5d2825f95800b541c.tar.gz rails-78b30fed9336336694fb2cb5d2825f95800b541c.tar.bz2 rails-78b30fed9336336694fb2cb5d2825f95800b541c.zip |
Correct default charset/collation for mysql dbs
Diffstat (limited to 'activerecord/lib/active_record/tasks')
-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 |