diff options
author | Matthew Draper <matthew@trebex.net> | 2019-04-09 09:44:04 +0930 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-09 09:44:04 +0930 |
commit | 95fee9438bfbd2130aba6e8bcd05ed28a77e7a85 (patch) | |
tree | c52a02c7af2901abd10bc820e78acd149d02d9f9 /activerecord/lib/active_record | |
parent | a497ece3f7046123cb7fe6720f08d40e4ca6019d (diff) | |
parent | 66762b81f45a4499a749378bbf14eb64bc097d3a (diff) | |
download | rails-95fee9438bfbd2130aba6e8bcd05ed28a77e7a85.tar.gz rails-95fee9438bfbd2130aba6e8bcd05ed28a77e7a85.tar.bz2 rails-95fee9438bfbd2130aba6e8bcd05ed28a77e7a85.zip |
Merge pull request #34800 from mqchau/mysqlCountDeleteRowInLock
Wrap Mysql count of deleted rows in lock block to avoid conflict in test
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb | 4 |
1 files changed, 3 insertions, 1 deletions
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 |