提交 252165ea 编写于 作者: Y Yasuo Honda

Remove 'if exists' from drop table statement then use `table_exists?`

Since 'drop table if exists' statement does not always work with
some databases such as Oracle.
上级 a2f8377d
...@@ -18,8 +18,8 @@ class Child < ActiveRecord::Base ...@@ -18,8 +18,8 @@ class Child < ActiveRecord::Base
end end
teardown do teardown do
@connection.execute("DROP TABLE IF EXISTS parents") @connection.execute("DROP TABLE parents") if @connection.table_exists? 'parents'
@connection.execute("DROP TABLE IF EXISTS children") @connection.execute("DROP TABLE children") if @connection.table_exists? 'children'
end end
test "belongs_to associations are not required by default" do test "belongs_to associations are not required by default" do
......
...@@ -28,7 +28,7 @@ def type_cast_from_user(value) ...@@ -28,7 +28,7 @@ def type_cast_from_user(value)
teardown do teardown do
return unless @connection 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.attribute_type_decorations.clear
Model.reset_column_information Model.reset_column_information
end end
......
...@@ -29,8 +29,8 @@ class Astronaut < ActiveRecord::Base ...@@ -29,8 +29,8 @@ class Astronaut < ActiveRecord::Base
teardown do teardown do
if defined?(@connection) if defined?(@connection)
@connection.execute "DROP TABLE IF EXISTS astronauts" @connection.execute "DROP TABLE astronauts" if @connection.table_exists? 'astronauts'
@connection.execute "DROP TABLE IF EXISTS rockets" @connection.execute "DROP TABLE rockets" if @connection.table_exists? 'rockets'
end end
end end
......
...@@ -441,7 +441,7 @@ class SchemaDumperDefaultsTest < ActiveRecord::TestCase ...@@ -441,7 +441,7 @@ class SchemaDumperDefaultsTest < ActiveRecord::TestCase
teardown do teardown do
return unless @connection return unless @connection
@connection.execute 'DROP TABLE IF EXISTS defaults' @connection.execute 'DROP TABLE defaults' if @connection.table_exists? 'defaults'
end end
def test_schema_dump_defaults_with_universally_supported_types def test_schema_dump_defaults_with_universally_supported_types
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册