_extract_error_code operates on wrong exception

Issue #1848 resolved
Former user created an issue

dialects.mysql.mysqldb._extract_error_code:

        try:
            return exception.orig.args[0](0)
        except AttributeError:
            return None

Exception passed by engine (through _handle_dbapi_exception, and then is_disconnected) is not DBAPIError instance, and therefore the exception does not attribute "orig"

To reproduce: Do any request to make sure that the connection created, and then restart the database and run the query again - because of this error, also method is_disconnected incorrectly returns False for appearing in this case, the exception.

Comments (5)

  1. Former user Account Deleted

    My mistake - exception passed right, but mysql.mysqldb dialect's function _extract_error_code proccess it in wrong way.

  2. Mike Bayer repo owner

    Unfortunately MySQLdb has an inconsistent interface making it impossible for us to cover this line of code, as issuing a close() on the underlying connection as we do now causes a different error scenario which is covered. The tests would need to start up a proxy server to the MySQL database and we then yank away the TCP connection (there is a way to do this).

    Additionally, the failure of the method doesn't cause a noticeable symptom unless one is watching the logs, as it appears that MySQLdb is already doing a reconnect in this situation. If you haven't observed this you should upgrade your MySQLdb. Whether or not the code is wrong, you get back a result for a subsequent execution.

    800448ad621a7cbe50726b6e208f55264dc623bc

  3. Mike Bayer repo owner
    • changed status to open
    • removed status

    that patch screwed things up since has_table() is sending the SQLA version into the method, also the other dialects also check "orig". fix shortly

  4. Log in to comment