From 66762b81f45a4499a749378bbf14eb64bc097d3a Mon Sep 17 00:00:00 2001 From: Quan Chau Date: Thu, 27 Dec 2018 10:59:18 -0800 Subject: Wrap Mysql count of deleted rows in lock block to avoid conflict in test --- .../active_record/connection_adapters/mysql/database_statements.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb') diff --git a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb index a14394fe04..2132e5d248 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb @@ -61,7 +61,9 @@ module ActiveRecord def exec_delete(sql, name = nil, binds = []) if without_prepared_statement?(binds) - execute_and_free(sql, name) { @connection.affected_rows } + @lock.synchronize do + execute_and_free(sql, name) { @connection.affected_rows } + end else exec_stmt_and_free(sql, name, binds) { |stmt| stmt.affected_rows } end -- cgit v1.2.3