提交 41e48c28 编写于 作者: J Jeremy Kemper

MySQL: skip GTID-unsafe statement tests when enforce_gtid_consistency is enabled

上级 67b42cb4
......@@ -66,12 +66,14 @@ def test_dump_indexes
assert_equal :fulltext, index_c.type
end
def test_drop_temporary_table
@connection.transaction do
@connection.create_table(:temp_table, temporary: true)
# if it doesn't properly say DROP TEMPORARY TABLE, the transaction commit
# will complain that no transaction is active
@connection.drop_table(:temp_table, temporary: true)
unless mysql_enforcing_gtid_consistency?
def test_drop_temporary_table
@connection.transaction do
@connection.create_table(:temp_table, temporary: true)
# if it doesn't properly say DROP TEMPORARY TABLE, the transaction commit
# will complain that no transaction is active
@connection.drop_table(:temp_table, temporary: true)
end
end
end
end
......
......@@ -50,6 +50,10 @@ def mysql_56?
ActiveRecord::Base.connection.send(:version).join(".") >= "5.6.0"
end
def mysql_enforcing_gtid_consistency?
current_adapter?(:MysqlAdapter, :Mysql2Adapter) && 'ON' == ActiveRecord::Base.connection.show_variable('enforce_gtid_consistency')
end
def supports_savepoints?
ActiveRecord::Base.connection.supports_savepoints?
end
......
......@@ -430,30 +430,32 @@ def test_create_table_with_binary_column
Person.connection.drop_table :binary_testings rescue nil
end
def test_create_table_with_query
Person.connection.drop_table :table_from_query_testings rescue nil
Person.connection.create_table(:person, force: true)
unless mysql_enforcing_gtid_consistency?
def test_create_table_with_query
Person.connection.drop_table :table_from_query_testings rescue nil
Person.connection.create_table(:person, force: true)
Person.connection.create_table :table_from_query_testings, as: "SELECT id FROM person"
Person.connection.create_table :table_from_query_testings, as: "SELECT id FROM person"
columns = Person.connection.columns(:table_from_query_testings)
assert_equal 1, columns.length
assert_equal "id", columns.first.name
columns = Person.connection.columns(:table_from_query_testings)
assert_equal 1, columns.length
assert_equal "id", columns.first.name
Person.connection.drop_table :table_from_query_testings rescue nil
end
Person.connection.drop_table :table_from_query_testings rescue nil
end
def test_create_table_with_query_from_relation
Person.connection.drop_table :table_from_query_testings rescue nil
Person.connection.create_table(:person, force: true)
def test_create_table_with_query_from_relation
Person.connection.drop_table :table_from_query_testings rescue nil
Person.connection.create_table(:person, force: true)
Person.connection.create_table :table_from_query_testings, as: Person.select(:id)
Person.connection.create_table :table_from_query_testings, as: Person.select(:id)
columns = Person.connection.columns(:table_from_query_testings)
assert_equal 1, columns.length
assert_equal "id", columns.first.name
columns = Person.connection.columns(:table_from_query_testings)
assert_equal 1, columns.length
assert_equal "id", columns.first.name
Person.connection.drop_table :table_from_query_testings rescue nil
Person.connection.drop_table :table_from_query_testings rescue nil
end
end
if current_adapter? :OracleAdapter
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册