aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRashmi Yadav <rays.rashmi@gmail.com>2011-04-25 23:05:17 +0530
committerRashmi Yadav <rays.rashmi@gmail.com>2011-04-25 23:05:17 +0530
commit6464f7b9be3ccf3f05a36bc6be0de2cb8ebda97d (patch)
treeec02ccb334e34cced9631326482a30d68182f630 /activerecord
parent17fec021d196ffbd745c340f98b9cfbcdb16b2a8 (diff)
downloadrails-6464f7b9be3ccf3f05a36bc6be0de2cb8ebda97d.tar.gz
rails-6464f7b9be3ccf3f05a36bc6be0de2cb8ebda97d.tar.bz2
rails-6464f7b9be3ccf3f05a36bc6be0de2cb8ebda97d.zip
Fixed error when running db:create with jdbcmysql
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/railties/databases.rake8
-rw-r--r--activerecord/lib/active_record/railties/jdbcmysql_error.rb16
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