From 6581d798e830a7820dd54fe95d40014c0e2057fe Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 12 Jan 2013 11:19:02 -0200 Subject: Fix AR tests due to Mysql constant not being defined --- activerecord/lib/active_record/tasks/mysql_database_tasks.rb | 10 +++++----- .../lib/active_record/tasks/postgresql_database_tasks.rb | 1 - activerecord/lib/active_record/tasks/sqlite_database_tasks.rb | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb index 3ae5aa2cea..1b4ed1cac4 100644 --- a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb @@ -1,7 +1,6 @@ module ActiveRecord module Tasks # :nodoc: class MySQLDatabaseTasks # :nodoc: - DEFAULT_CHARSET = ENV['CHARSET'] || 'utf8' DEFAULT_COLLATION = ENV['COLLATION'] || 'utf8_unicode_ci' ACCESS_DENIED_ERROR = 1045 @@ -24,7 +23,7 @@ module ActiveRecord connection.create_database configuration['database'], creation_options connection.execute grant_statement.gsub(/\s+/, ' ').strip establish_connection configuration - rescue error_class, ActiveRecord::StatementInvalid => error + rescue ActiveRecord::StatementInvalid, error_class => error if /database exists/ === error.message raise DatabaseAlreadyExists else @@ -93,8 +92,10 @@ module ActiveRecord if configuration['adapter'] =~ /jdbc/ require 'active_record/railties/jdbcmysql_error' ArJdbcMySQL::Error - else - defined?(Mysql2) ? Mysql2::Error : Mysql::Error + elsif defined?(Mysql2) + Mysql2::Error + elsif defined?(Mysql) + Mysql::Error end end @@ -128,7 +129,6 @@ IDENTIFIED BY '#{configuration['password']}' WITH GRANT OPTION; end args end - end end end diff --git a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb index e6a85b1917..0b1b030516 100644 --- a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb @@ -3,7 +3,6 @@ require 'shellwords' module ActiveRecord module Tasks # :nodoc: class PostgreSQLDatabaseTasks # :nodoc: - DEFAULT_ENCODING = ENV['CHARSET'] || 'utf8' delegate :connection, :establish_connection, :clear_active_connections!, diff --git a/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb b/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb index 33c43c7774..de8b16627e 100644 --- a/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb @@ -1,7 +1,6 @@ module ActiveRecord module Tasks # :nodoc: class SQLiteDatabaseTasks # :nodoc: - delegate :connection, :establish_connection, to: ActiveRecord::Base def initialize(configuration, root = Rails.root) -- cgit v1.2.3