Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove adapter specific codes. Because we must support unknown adapter.

  • Loading branch information...
commit 4217ede94f0fa289ab2ccbc5ff3a9eb264adc599 1 parent 7121b38
@kennyj authored
View
21 activerecord/lib/active_record/railties/databases.rake
@@ -271,12 +271,7 @@ db_namespace = namespace :db do
task :dump => [:environment, :load_config] do
abcs = ActiveRecord::Base.configurations
filename = ENV['DB_STRUCTURE'] || File.join(Rails.root, "db", "structure.sql")
- case abcs[Rails.env]['adapter']
- when /mysql/, /postgresql/, /sqlite/
- ActiveRecord::Tasks::DatabaseTasks.structure_dump(abcs[Rails.env], filename)
- else
- raise "Task not supported by '#{abcs[Rails.env]["adapter"]}'"
- end
+ ActiveRecord::Tasks::DatabaseTasks.structure_dump(abcs[Rails.env], filename)
if ActiveRecord::Base.connection.supports_migrations?
File.open(filename, "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
@@ -290,12 +285,7 @@ db_namespace = namespace :db do
abcs = ActiveRecord::Base.configurations
filename = ENV['DB_STRUCTURE'] || File.join(Rails.root, "db", "structure.sql")
- case abcs[env]['adapter']
- when /mysql/, /postgresql/, /sqlite/
- ActiveRecord::Tasks::DatabaseTasks.structure_load(abcs[env], filename)
- else
- raise "Task not supported by '#{abcs[env]['adapter']}'"
- end
+ ActiveRecord::Tasks::DatabaseTasks.structure_load(abcs[env], filename)
end
task :load_if_sql => 'db:create' do
@@ -351,12 +341,7 @@ db_namespace = namespace :db do
# desc "Empty the test database"
task :purge => [:environment, :load_config] do
abcs = ActiveRecord::Base.configurations
- case abcs['test']['adapter']
- when /mysql/, /postgresql/, /sqlite/
- ActiveRecord::Tasks::DatabaseTasks.purge abcs['test']
- else
- raise "Task not supported by '#{abcs['test']['adapter']}'"
- end
+ ActiveRecord::Tasks::DatabaseTasks.purge abcs['test']
end
# desc 'Check for pending migrations and load the test schema'
View
1  activerecord/lib/active_record/tasks/database_tasks.rb
@@ -89,6 +89,7 @@ def structure_load(*arguments)
def class_for_adapter(adapter)
key = @tasks.keys.detect { |pattern| adapter[pattern] }
+ raise "Not found database tasks class for '#{adapter}'" unless key
@tasks[key]
end
View
2  activerecord/test/cases/tasks/database_tasks_test.rb
@@ -30,6 +30,8 @@ def structure_dump(filename); end
ActiveRecord::Tasks::DatabaseTasks.register_task(/foo/, klazz)
ActiveRecord::Tasks::DatabaseTasks.structure_dump({'adapter' => :foo}, "awesome-file.sql")
+
+ assert_raise(RuntimeError) { ActiveRecord::Tasks::DatabaseTasks.structure_dump({'adapter' => :bar}, "awesome-file.sql") }
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.