diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-08-25 23:05:21 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-10-30 20:10:09 +0000 |
commit | c4867b88f6eed16230a90077b82ad02293ea45b3 (patch) | |
tree | 6d51ed5dd043515add818674c374d6325783d9a0 /activerecord/lib/active_record/tasks | |
parent | 13c5aa818e9284fe30f83469b340e579195bda3f (diff) | |
download | rails-c4867b88f6eed16230a90077b82ad02293ea45b3.tar.gz rails-c4867b88f6eed16230a90077b82ad02293ea45b3.tar.bz2 rails-c4867b88f6eed16230a90077b82ad02293ea45b3.zip |
Raise error if unsupported charset for mysql
`blog$ bin/rails db:create`
Before:
```
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5,
"username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock",
"database"=>"blog_development"}, {:charset=>"utf42"}
(If you set the charset manually, make sure you have a matching collation)
Created database 'blog_development'
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5,
"username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock",
"database"=>"blog_test"}, {:charset=>"utf42"}
(If you set the charset manually, make sure you have a matching collation)
Created database 'blog_test'
```
After:
```
Unsupported charset: '"utf42"'
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5,
"username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock",
"database"=>"blog_development"}
rails aborted!
Mysql2::Error: Unsupported charset: '"utf42"'
...
(stack trace)
...
bin/rails:4:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
```
Closes #29683
Related to #27398
Diffstat (limited to 'activerecord/lib/active_record/tasks')
-rw-r--r-- | activerecord/lib/active_record/tasks/mysql_database_tasks.rb | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb index 2f91884f59..d6a46f7743 100644 --- a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb @@ -31,9 +31,7 @@ module ActiveRecord end establish_connection configuration else - $stderr.puts error.inspect - $stderr.puts "Couldn't create database for #{configuration.inspect}, #{creation_options.inspect}" - $stderr.puts "(If you set the charset manually, make sure you have a matching collation)" if configuration["encoding"] + raise end end |