mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
prefer drop_table if_exists: true
over raw SQL.
/cc @yahonda This makes it easier for third party adapters to run our tests, even if that database does not support IF EXISTS.
This commit is contained in:
parent
1e27e7d72d
commit
07b659ca3f
12 changed files with 12 additions and 12 deletions
|
@ -15,7 +15,7 @@ module ActiveRecord
|
|||
assert_raise ActiveRecord::NoDatabaseError do
|
||||
configuration = ActiveRecord::Base.configurations['arunit'].merge(database: 'inexistent_activerecord_unittest')
|
||||
connection = ActiveRecord::Base.mysql_connection(configuration)
|
||||
connection.exec_query('drop table if exists ex')
|
||||
connection.drop_table 'ex', if_exists: true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
teardown do
|
||||
@connection.execute "drop table if exists mysql_doubles"
|
||||
@connection.drop_table "mysql_doubles", if_exists: true
|
||||
end
|
||||
|
||||
class MysqlDouble < ActiveRecord::Base
|
||||
|
|
|
@ -22,7 +22,7 @@ class MysqlConnectionTest < ActiveRecord::TestCase
|
|||
assert_raise ActiveRecord::NoDatabaseError do
|
||||
configuration = ActiveRecord::Base.configurations['arunit'].merge(database: 'inexistent_activerecord_unittest')
|
||||
connection = ActiveRecord::Base.mysql2_connection(configuration)
|
||||
connection.exec_query('drop table if exists ex')
|
||||
connection.drop_table 'ex', if_exists: true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class PostgresqlArrayTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
teardown do
|
||||
@connection.execute 'drop table if exists pg_arrays'
|
||||
@connection.drop_table 'pg_arrays', if_exists: true
|
||||
disable_extension!('hstore', @connection)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class PostgresqlByteaTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
teardown do
|
||||
@connection.execute 'drop table if exists bytea_data_type'
|
||||
@connection.drop_table 'bytea_data_type', if_exists: true
|
||||
end
|
||||
|
||||
def test_column
|
||||
|
|
|
@ -32,7 +32,7 @@ if ActiveRecord::Base.connection.supports_extensions?
|
|||
end
|
||||
|
||||
teardown do
|
||||
@connection.execute 'drop table if exists hstores'
|
||||
@connection.drop_table 'hstores', if_exists: true
|
||||
end
|
||||
|
||||
def test_hstore_included_in_extensions
|
||||
|
|
|
@ -16,7 +16,7 @@ class PostgresqlIntegerTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
teardown do
|
||||
@connection.execute "drop table if exists pg_integers"
|
||||
@connection.drop_table "pg_integers", if_exists: true
|
||||
end
|
||||
|
||||
test "schema properly respects bigint ranges" do
|
||||
|
|
|
@ -22,7 +22,7 @@ class PostgresqlLtreeTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
teardown do
|
||||
@connection.execute 'drop table if exists ltrees'
|
||||
@connection.drop_table 'ltrees', if_exists: true
|
||||
end
|
||||
|
||||
def test_column
|
||||
|
|
|
@ -7,7 +7,7 @@ module PostgresqlUUIDHelper
|
|||
end
|
||||
|
||||
def drop_table(name)
|
||||
connection.execute "drop table if exists #{name}"
|
||||
connection.drop_table name, if_exists: true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class PostgresqlXMLTest < ActiveRecord::TestCase
|
|||
end
|
||||
|
||||
teardown do
|
||||
@connection.execute 'drop table if exists xml_data_type'
|
||||
@connection.drop_table 'xml_data_type', if_exists: true
|
||||
end
|
||||
|
||||
def test_column
|
||||
|
|
|
@ -22,7 +22,7 @@ module ActiveRecord
|
|||
def test_bad_connection
|
||||
assert_raise ActiveRecord::NoDatabaseError do
|
||||
connection = ActiveRecord::Base.sqlite3_connection(adapter: "sqlite3", database: "/tmp/should/_not/_exist/-cinco-dog.db")
|
||||
connection.exec_query('drop table if exists ex')
|
||||
connection.drop_table 'ex', if_exists: true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -668,7 +668,7 @@ class TransactionTest < ActiveRecord::TestCase
|
|||
end
|
||||
end
|
||||
ensure
|
||||
connection.execute("DROP TABLE IF EXISTS transaction_without_primary_keys")
|
||||
connection.drop_table 'transaction_without_primary_keys', if_exists: true
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue