diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-07 11:48:29 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-07 11:48:29 -0800 |
commit | 2ee4c8d90b6818867ad371907cb7d3c763318c3b (patch) | |
tree | 7ac8f40a3d1ffe9b56796004f100120c8e0f285b /activerecord | |
parent | 839f3bf6822ed3698df1e606c4215d650312f33e (diff) | |
download | rails-2ee4c8d90b6818867ad371907cb7d3c763318c3b.tar.gz rails-2ee4c8d90b6818867ad371907cb7d3c763318c3b.tar.bz2 rails-2ee4c8d90b6818867ad371907cb7d3c763318c3b.zip |
only rescue from Mysql::Error exceptions [#6236 state:resolved]
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 43de9c2090..47acf0b254 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -364,9 +364,14 @@ module ActiveRecord # statement API. For those queries, we need to use this method. :'( log(sql, name) do result = @connection.query(sql) - cols = result.fetch_fields.map { |field| field.name } - rows = result.to_a - result.free + cols = [] + rows = [] + + if result + cols = result.fetch_fields.map { |field| field.name } + rows = result.to_a + result.free + end ActiveRecord::Result.new(cols, rows) end end @@ -400,7 +405,7 @@ module ActiveRecord def begin_db_transaction #:nodoc: exec_without_stmt "BEGIN" - rescue Exception + rescue Mysql::Error # Transactions aren't supported end |