From 42d0d1832f3354dbbd61163c2bb9a7a50227d98b Mon Sep 17 00:00:00 2001 From: kennyj Date: Wed, 5 Jun 2013 20:53:26 +0900 Subject: [PATCH 1/3] Remove OracleDatabaseTasks was deprecated, because this was provided by 3rd-party. --- .../lib/active_record/tasks/database_tasks.rb | 1 - .../tasks/oracle_database_tasks.rb | 45 --------- .../test/cases/tasks/oracle_rake_test.rb | 93 ------------------- 3 files changed, 139 deletions(-) delete mode 100644 activerecord/lib/active_record/tasks/oracle_database_tasks.rb delete mode 100644 activerecord/test/cases/tasks/oracle_rake_test.rb diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 3e8b79c7a0..45a1f7838a 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -52,7 +52,6 @@ module ActiveRecord register_task(/firebird/, ActiveRecord::Tasks::FirebirdDatabaseTasks) register_task(/sqlserver/, ActiveRecord::Tasks::SqlserverDatabaseTasks) - register_task(/(oci|oracle)/, ActiveRecord::Tasks::OracleDatabaseTasks) def current_config(options = {}) options.reverse_merge! :env => env diff --git a/activerecord/lib/active_record/tasks/oracle_database_tasks.rb b/activerecord/lib/active_record/tasks/oracle_database_tasks.rb deleted file mode 100644 index de3aa50e5e..0000000000 --- a/activerecord/lib/active_record/tasks/oracle_database_tasks.rb +++ /dev/null @@ -1,45 +0,0 @@ -module ActiveRecord - module Tasks # :nodoc: - class OracleDatabaseTasks # :nodoc: - delegate :connection, :establish_connection, to: ActiveRecord::Base - - def initialize(configuration) - ActiveSupport::Deprecation.warn "This database tasks were deprecated, because this tasks should be served by the 3rd party adapter." - @configuration = configuration - end - - def create - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def drop - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def purge - establish_connection(:test) - connection.structure_drop.split(";\n\n").each { |ddl| connection.execute(ddl) } - end - - def charset - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def structure_dump(filename) - establish_connection(configuration) - File.open(filename, "w:utf-8") { |f| f << connection.structure_dump } - end - - def structure_load(filename) - establish_connection(configuration) - IO.read(filename).split(";\n\n").each { |ddl| connection.execute(ddl) } - end - - private - - def configuration - @configuration - end - end - end -end diff --git a/activerecord/test/cases/tasks/oracle_rake_test.rb b/activerecord/test/cases/tasks/oracle_rake_test.rb deleted file mode 100644 index 5f840febbc..0000000000 --- a/activerecord/test/cases/tasks/oracle_rake_test.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'cases/helper' - -module ActiveRecord - module OracleSetupper - def setup - @database = 'db.oracle' - @connection = stub :connection - @configuration = { - 'adapter' => 'oracle', - 'database' => @database - } - ActiveRecord::Base.stubs(:connection).returns(@connection) - ActiveRecord::Base.stubs(:establish_connection).returns(true) - - @tasks = Class.new(ActiveRecord::Tasks::OracleDatabaseTasks) do - def initialize(configuration) - ActiveSupport::Deprecation.silence { super } - end - end - ActiveRecord::Tasks::DatabaseTasks.stubs(:class_for_adapter).returns(@tasks) unless defined? ActiveRecord::ConnectionAdapters::OracleAdapter - end - end - - class OracleDBCreateTest < ActiveRecord::TestCase - include OracleSetupper - - def test_db_retrieves_create - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.create @configuration - end - assert_match(/not supported/, message) - end - end - - class OracleDBDropTest < ActiveRecord::TestCase - include OracleSetupper - - def test_db_retrieves_drop - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.drop @configuration - end - assert_match(/not supported/, message) - end - end - - class OracleDBCharsetAndCollationTest < ActiveRecord::TestCase - include OracleSetupper - - def test_db_retrieves_collation - assert_raise NoMethodError do - ActiveRecord::Tasks::DatabaseTasks.collation @configuration - end - end - - def test_db_retrieves_charset - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.charset @configuration - end - assert_match(/not supported/, message) - end - end - - class OracleStructureDumpTest < ActiveRecord::TestCase - include OracleSetupper - - def setup - super - @connection.stubs(:structure_dump).returns("select sysdate from dual;") - end - - def test_structure_dump - filename = "oracle.sql" - ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename) - assert File.exists?(filename) - ensure - FileUtils.rm_f(filename) - end - end - - class OracleStructureLoadTest < ActiveRecord::TestCase - include OracleSetupper - - def test_structure_load - filename = "oracle.sql" - - open(filename, 'w') { |f| f.puts("select sysdate from dual;") } - @connection.stubs(:execute).with("select sysdate from dual;\n") - ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename) - ensure - FileUtils.rm_f(filename) - end - end -end From 6b16b2f0f3f3a6800640024f729b862c05d1aa2d Mon Sep 17 00:00:00 2001 From: kennyj Date: Wed, 5 Jun 2013 20:54:11 +0900 Subject: [PATCH 2/3] Remove SqlseverDatabaseTasks was deprecated, because this was provided by 3rd-party. --- .../lib/active_record/tasks/database_tasks.rb | 1 - .../tasks/sqlserver_database_tasks.rb | 48 ---------- .../test/cases/tasks/sqlserver_rake_test.rb | 87 ------------------- 3 files changed, 136 deletions(-) delete mode 100644 activerecord/lib/active_record/tasks/sqlserver_database_tasks.rb delete mode 100644 activerecord/test/cases/tasks/sqlserver_rake_test.rb diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 45a1f7838a..6fc8db0bfe 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -51,7 +51,6 @@ module ActiveRecord register_task(/sqlite/, ActiveRecord::Tasks::SQLiteDatabaseTasks) register_task(/firebird/, ActiveRecord::Tasks::FirebirdDatabaseTasks) - register_task(/sqlserver/, ActiveRecord::Tasks::SqlserverDatabaseTasks) def current_config(options = {}) options.reverse_merge! :env => env diff --git a/activerecord/lib/active_record/tasks/sqlserver_database_tasks.rb b/activerecord/lib/active_record/tasks/sqlserver_database_tasks.rb deleted file mode 100644 index c718ee03a8..0000000000 --- a/activerecord/lib/active_record/tasks/sqlserver_database_tasks.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'shellwords' - -module ActiveRecord - module Tasks # :nodoc: - class SqlserverDatabaseTasks # :nodoc: - delegate :connection, :establish_connection, to: ActiveRecord::Base - - def initialize(configuration) - ActiveSupport::Deprecation.warn "This database tasks were deprecated, because this tasks should be served by the 3rd party adapter." - @configuration = configuration - end - - def create - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def drop - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def purge - test = configuration.deep_dup - test_database = test['database'] - test['database'] = 'master' - establish_connection(test) - connection.recreate_database!(test_database) - end - - def charset - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def structure_dump(filename) - Kernel.system("smoscript -s #{configuration['host']} -d #{configuration['database']} -u #{configuration['username']} -p #{configuration['password']} -f #{filename} -A -U") - end - - def structure_load(filename) - Kernel.system("sqlcmd -S #{configuration['host']} -d #{configuration['database']} -U #{configuration['username']} -P #{configuration['password']} -i #{filename}") - end - - private - - def configuration - @configuration - end - end - end -end diff --git a/activerecord/test/cases/tasks/sqlserver_rake_test.rb b/activerecord/test/cases/tasks/sqlserver_rake_test.rb deleted file mode 100644 index 0f1264b8ce..0000000000 --- a/activerecord/test/cases/tasks/sqlserver_rake_test.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'cases/helper' - -module ActiveRecord - module SqlserverSetupper - def setup - @database = 'db.sqlserver' - @connection = stub :connection - @configuration = { - 'adapter' => 'sqlserver', - 'database' => @database, - 'host' => 'localhost', - 'username' => 'username', - 'password' => 'password', - } - ActiveRecord::Base.stubs(:connection).returns(@connection) - ActiveRecord::Base.stubs(:establish_connection).returns(true) - - @tasks = Class.new(ActiveRecord::Tasks::SqlserverDatabaseTasks) do - def initialize(configuration) - ActiveSupport::Deprecation.silence { super } - end - end - ActiveRecord::Tasks::DatabaseTasks.stubs(:class_for_adapter).returns(@tasks) unless defined? ActiveRecord::ConnectionAdapters::SQLServerAdapter - end - end - - class SqlserverDBCreateTest < ActiveRecord::TestCase - include SqlserverSetupper - - def test_db_retrieves_create - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.create @configuration - end - assert_match(/not supported/, message) - end - end - - class SqlserverDBDropTest < ActiveRecord::TestCase - include SqlserverSetupper - - def test_db_retrieves_drop - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.drop @configuration - end - assert_match(/not supported/, message) - end - end - - class SqlserverDBCharsetAndCollationTest < ActiveRecord::TestCase - include SqlserverSetupper - - def test_db_retrieves_collation - assert_raise NoMethodError do - ActiveRecord::Tasks::DatabaseTasks.collation @configuration - end - end - - def test_db_retrieves_charset - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.charset @configuration - end - assert_match(/not supported/, message) - end - end - - class SqlserverStructureDumpTest < ActiveRecord::TestCase - include SqlserverSetupper - - def test_structure_dump - filename = "sqlserver.sql" - Kernel.expects(:system).with("smoscript -s localhost -d #{@database} -u username -p password -f #{filename} -A -U") - - ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename) - end - end - - class SqlserverStructureLoadTest < ActiveRecord::TestCase - include SqlserverSetupper - - def test_structure_load - filename = "sqlserver.sql" - Kernel.expects(:system).with("sqlcmd -S localhost -d #{@database} -U username -P password -i #{filename}") - - ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename) - end - end -end From 6649140120a5a6456d7fc63841d90d19a78b3b8c Mon Sep 17 00:00:00 2001 From: kennyj Date: Wed, 5 Jun 2013 20:54:39 +0900 Subject: [PATCH 3/3] Remove FirebirdDatabaseTasks was deprecated, because this was provided by 3rd-party. --- .../lib/active_record/tasks/database_tasks.rb | 2 - .../tasks/firebird_database_tasks.rb | 56 ---------- .../test/cases/tasks/firebird_rake_test.rb | 100 ------------------ 3 files changed, 158 deletions(-) delete mode 100644 activerecord/lib/active_record/tasks/firebird_database_tasks.rb delete mode 100644 activerecord/test/cases/tasks/firebird_rake_test.rb diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 6fc8db0bfe..5ff594fdca 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -50,8 +50,6 @@ module ActiveRecord register_task(/postgresql/, ActiveRecord::Tasks::PostgreSQLDatabaseTasks) register_task(/sqlite/, ActiveRecord::Tasks::SQLiteDatabaseTasks) - register_task(/firebird/, ActiveRecord::Tasks::FirebirdDatabaseTasks) - def current_config(options = {}) options.reverse_merge! :env => env if options.has_key?(:config) diff --git a/activerecord/lib/active_record/tasks/firebird_database_tasks.rb b/activerecord/lib/active_record/tasks/firebird_database_tasks.rb deleted file mode 100644 index 98014a38ea..0000000000 --- a/activerecord/lib/active_record/tasks/firebird_database_tasks.rb +++ /dev/null @@ -1,56 +0,0 @@ -module ActiveRecord - module Tasks # :nodoc: - class FirebirdDatabaseTasks # :nodoc: - delegate :connection, :establish_connection, to: ActiveRecord::Base - - def initialize(configuration) - ActiveSupport::Deprecation.warn "This database tasks were deprecated, because this tasks should be served by the 3rd party adapter." - @configuration = configuration - end - - def create - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def drop - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def purge - establish_connection(:test) - connection.recreate_database! - end - - def charset - $stderr.puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' - end - - def structure_dump(filename) - set_firebird_env(configuration) - db_string = firebird_db_string(configuration) - Kernel.system "isql -a #{db_string} > #{filename}" - end - - def structure_load(filename) - set_firebird_env(configuration) - db_string = firebird_db_string(configuration) - Kernel.system "isql -i #{filename} #{db_string}" - end - - private - - def set_firebird_env(config) - ENV['ISC_USER'] = config['username'].to_s if config['username'] - ENV['ISC_PASSWORD'] = config['password'].to_s if config['password'] - end - - def firebird_db_string(config) - FireRuby::Database.db_string_for(config.symbolize_keys) - end - - def configuration - @configuration - end - end - end -end diff --git a/activerecord/test/cases/tasks/firebird_rake_test.rb b/activerecord/test/cases/tasks/firebird_rake_test.rb deleted file mode 100644 index c54989ae34..0000000000 --- a/activerecord/test/cases/tasks/firebird_rake_test.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'cases/helper' - -unless defined?(FireRuby::Database) -module FireRuby - module Database; end -end -end - -module ActiveRecord - module FirebirdSetupper - def setup - @database = 'db.firebird' - @connection = stub :connection - @configuration = { - 'adapter' => 'firebird', - 'database' => @database - } - ActiveRecord::Base.stubs(:connection).returns(@connection) - ActiveRecord::Base.stubs(:establish_connection).returns(true) - - @tasks = Class.new(ActiveRecord::Tasks::FirebirdDatabaseTasks) do - def initialize(configuration) - ActiveSupport::Deprecation.silence { super } - end - end - ActiveRecord::Tasks::DatabaseTasks.stubs(:class_for_adapter).returns(@tasks) unless defined? ActiveRecord::ConnectionAdapters::FirebirdAdapter - end - end - - class FirebirdDBCreateTest < ActiveRecord::TestCase - include FirebirdSetupper - - def test_db_retrieves_create - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.create @configuration - end - assert_match(/not supported/, message) - end - end - - class FirebirdDBDropTest < ActiveRecord::TestCase - include FirebirdSetupper - - def test_db_retrieves_drop - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.drop @configuration - end - assert_match(/not supported/, message) - end - end - - class FirebirdDBCharsetAndCollationTest < ActiveRecord::TestCase - include FirebirdSetupper - - def test_db_retrieves_collation - assert_raise NoMethodError do - ActiveRecord::Tasks::DatabaseTasks.collation @configuration - end - end - - def test_db_retrieves_charset - message = capture(:stderr) do - ActiveRecord::Tasks::DatabaseTasks.charset @configuration - end - assert_match(/not supported/, message) - end - end - - class FirebirdStructureDumpTest < ActiveRecord::TestCase - include FirebirdSetupper - - def setup - super - FireRuby::Database.stubs(:db_string_for).returns(@database) - end - - def test_structure_dump - filename = "filebird.sql" - Kernel.expects(:system).with("isql -a #{@database} > #{filename}") - - ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename) - end - end - - class FirebirdStructureLoadTest < ActiveRecord::TestCase - include FirebirdSetupper - - def setup - super - FireRuby::Database.stubs(:db_string_for).returns(@database) - end - - def test_structure_load - filename = "firebird.sql" - Kernel.expects(:system).with("isql -i #{filename} #{@database}") - - ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename) - end - end -end