Skip to content

Commit 2ee4c8d

Browse files
committed
only rescue from Mysql::Error exceptions [rails#6236 state:resolved]
1 parent 839f3bf commit 2ee4c8d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,14 @@ def exec_without_stmt(sql, name = 'SQL') # :nodoc:
364364
# statement API. For those queries, we need to use this method. :'(
365365
log(sql, name) do
366366
result = @connection.query(sql)
367-
cols = result.fetch_fields.map { |field| field.name }
368-
rows = result.to_a
369-
result.free
367+
cols = []
368+
rows = []
369+
370+
if result
371+
cols = result.fetch_fields.map { |field| field.name }
372+
rows = result.to_a
373+
result.free
374+
end
370375
ActiveRecord::Result.new(cols, rows)
371376
end
372377
end
@@ -400,7 +405,7 @@ def update_sql(sql, name = nil) #:nodoc:
400405

401406
def begin_db_transaction #:nodoc:
402407
exec_without_stmt "BEGIN"
403-
rescue Exception
408+
rescue Mysql::Error
404409
# Transactions aren't supported
405410
end
406411

0 commit comments

Comments
 (0)