This project is archived and is in readonly mode.

#6236 ✓resolved
Jon Leighton

NoMethodError: undefined method `fetch_fields' for nil:NilClass: BEGIN

Reported by Jon Leighton | December 30th, 2010 @ 10:55 PM | in 3.x

This is showing up in the debug.log when running the Active Record tests under the mysql adapter (not mysql2).

The exception is printed to the log file by AbstractAdapter#log, but then caught by "rescue Exception" in MysqlAdapter#begin_db_transaction. There are two issues here:

  1. The error seems to have been introduced by this commit: https://github.com/rails/rails/commit/efc10a8a64d5748bc8355c0bd0373.... Changing exec_without_stmt back to execute prevents it.

  2. The error would have been more obvious if that MysqlAdapter#begin_db_transaction wasn't using "rescue Exception" as a way to test for transaction support. My hunch would be that it would be sufficient to check for Mysql::Error or Mysql2::Error, depending on which driver is in use. However, I don't know this for sure and I'm not sure how to create a situation where the mysql server will throw an error indicating a lack of support for transactions, so I will defer to greater wisdom :)

Cheers

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages