diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-25 11:17:16 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-25 11:17:16 -0700 |
commit | 12427c8dea1e817d7badc06f1f21af989c0f56ea (patch) | |
tree | 0eb973f63bba1a1fb140a5128bf8d2f34b2e88b5 | |
parent | f3c335f1cd6ab74e6feb2fc51d0315e29f555473 (diff) | |
parent | 6464f7b9be3ccf3f05a36bc6be0de2cb8ebda97d (diff) | |
download | rails-12427c8dea1e817d7badc06f1f21af989c0f56ea.tar.gz rails-12427c8dea1e817d7badc06f1f21af989c0f56ea.tar.bz2 rails-12427c8dea1e817d7badc06f1f21af989c0f56ea.zip |
Merged pull request #304 from arunagw/jdbcmysql_db_create.
Fixed error when running db:create with jdbcmysql
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/railties/jdbcmysql_error.rb | 16 |
2 files changed, 23 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 6b3c38cb58..a49f940e5b 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -70,7 +70,13 @@ db_namespace = namespace :db do @charset = ENV['CHARSET'] || 'utf8' @collation = ENV['COLLATION'] || 'utf8_unicode_ci' creation_options = {:charset => (config['charset'] || @charset), :collation => (config['collation'] || @collation)} - error_class = config['adapter'] =~ /mysql2/ ? Mysql2::Error : Mysql::Error + if config['adapter'] =~ /jdbc/ + #FIXME After Jdbcmysql gives this class + require 'active_record/railties/jdbcmysql_error' + error_class = ArJdbcMySQL::Error + else + error_class = config['adapter'] =~ /mysql2/ ? Mysql2::Error : Mysql::Error + end access_denied_error = 1045 begin ActiveRecord::Base.establish_connection(config.merge('database' => nil)) diff --git a/activerecord/lib/active_record/railties/jdbcmysql_error.rb b/activerecord/lib/active_record/railties/jdbcmysql_error.rb new file mode 100644 index 0000000000..6b9af2a0cb --- /dev/null +++ b/activerecord/lib/active_record/railties/jdbcmysql_error.rb @@ -0,0 +1,16 @@ +#FIXME Remove if ArJdbcMysql will give. +module ArJdbcMySQL + class Error < StandardError + attr_accessor :error_number, :sql_state + + def initialize msg + super + @error_number = nil + @sql_state = nil + end + + # Mysql gem compatibility + alias_method :errno, :error_number + alias_method :error, :message + end +end |