zzzeek/sqlalchemy — pull request #148 by pbu88 (2014-11-05 12:32:12+00:00)
Title: Small improvement on FlushError can't delete error message

Output in the error message the table name and the column name.

The lack of this information drove me mad for the last couple of days. I had an object with a lot of relationships and cascading deletes that I couldn't delete. I got `"FlushError: Can't delete from table using NULL for primary key value"`.

At first I try to hunt down which table was the problematic one. I even enabled debug loggin for SQLAlchemy but sadly this didn't help because apparently it output the sql *after* the execution (maybe I'm wrong but I couldn't see the actual problematic query this way). The hunt was driving me crazy because this object had a lot of relationships like I said, so eventually, I saw the table and column information was immediately available in the sqlalchemy method where the exception was being raise so I just added this patch and immediately got the feedback of the faulty table and column.

Is not a big change, I guess it doesn't hurt to output this info when throwing the error.