diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 765cdf90d21e4..fddb3185539dc 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -383,7 +383,7 @@ def exec_stmt(sql, name, binds, cache_stmt: false) type_casted_binds = binds.map { |attr| type_cast(attr.value_for_database) } log(sql, name, binds) do - if binds.empty? || !cache_stmt + if !cache_stmt stmt = @connection.prepare(sql) else cache = @statements[sql] ||= { @@ -399,7 +399,7 @@ def exec_stmt(sql, name, binds, cache_stmt: false) # place when an error occurs. To support older MySQL versions, we # need to close the statement and delete the statement from the # cache. - if binds.empty? || !cache_stmt + if !cache_stmt stmt.close else @statements.delete sql @@ -417,7 +417,7 @@ def exec_stmt(sql, name, binds, cache_stmt: false) affected_rows = stmt.affected_rows stmt.free_result - stmt.close if binds.empty? + stmt.close if !cache_stmt [result_set, affected_rows] end