Skip to content

Commit

Permalink
Remove 'if exists' from drop table statement then use table_exists?
Browse files Browse the repository at this point in the history
Since 'drop table if exists' statement does not always work with
some databases such as Oracle.
  • Loading branch information
yahonda committed Sep 2, 2014
1 parent a2f8377 commit 252165e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions activerecord/test/cases/associations/required_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class Child < ActiveRecord::Base
end

teardown do
@connection.execute("DROP TABLE IF EXISTS parents")
@connection.execute("DROP TABLE IF EXISTS children")
@connection.execute("DROP TABLE parents") if @connection.table_exists? 'parents'
@connection.execute("DROP TABLE children") if @connection.table_exists? 'children'
end

test "belongs_to associations are not required by default" do
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/attribute_decorators_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def type_cast_from_user(value)

teardown do
return unless @connection
@connection.execute 'DROP TABLE IF EXISTS attribute_decorators_model'
@connection.execute 'DROP TABLE attribute_decorators_model' if @connection.table_exists? 'attribute_decorators_model'
Model.attribute_type_decorations.clear
Model.reset_column_information
end
Expand Down
4 changes: 2 additions & 2 deletions activerecord/test/cases/migration/foreign_key_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Astronaut < ActiveRecord::Base

teardown do
if defined?(@connection)
@connection.execute "DROP TABLE IF EXISTS astronauts"
@connection.execute "DROP TABLE IF EXISTS rockets"
@connection.execute "DROP TABLE astronauts" if @connection.table_exists? 'astronauts'
@connection.execute "DROP TABLE rockets" if @connection.table_exists? 'rockets'
end
end

Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/schema_dumper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class SchemaDumperDefaultsTest < ActiveRecord::TestCase

teardown do
return unless @connection
@connection.execute 'DROP TABLE IF EXISTS defaults'
@connection.execute 'DROP TABLE defaults' if @connection.table_exists? 'defaults'
end

def test_schema_dump_defaults_with_universally_supported_types
Expand Down

0 comments on commit 252165e

Please sign in to comment.