Skip to content

Commit

Permalink
Merged pull request rails#304 from arunagw/jdbcmysql_db_create.
Browse files Browse the repository at this point in the history
Fixed error when running db:create with jdbcmysql
  • Loading branch information
tenderlove committed Apr 25, 2011
2 parents f3c335f + 6464f7b commit 12427c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion activerecord/lib/active_record/railties/databases.rake
Expand Up @@ -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))
Expand Down
16 changes: 16 additions & 0 deletions 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

0 comments on commit 12427c8

Please sign in to comment.