]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Small improvement on FlushError can't delete error message
authorPaulo Bu <pbu_98@yahoo.com>
Wed, 5 Nov 2014 12:15:08 +0000 (13:15 +0100)
committerPaulo Bu <pbu_98@yahoo.com>
Wed, 5 Nov 2014 12:23:03 +0000 (13:23 +0100)
Output in the error message the table name and the column name.

lib/sqlalchemy/orm/persistence.py
test/orm/test_unitofwork.py

index 114b79ea543659b77ee8bf34a0e21d5fd8aeb3fc..28254cc1033866230529c4cd95654d551643dc0f 100644 (file)
@@ -441,9 +441,9 @@ def _collect_delete_commands(base_mapper, uowtransaction, table,
                     state, state_dict, col)
             if value is None:
                 raise orm_exc.FlushError(
-                    "Can't delete from table "
+                    "Can't delete from table %s "
                     "using NULL for primary "
-                    "key value")
+                    "key value on column %s" % (table, col))
 
         if update_version_id is not None and \
                 table.c.contains_column(mapper.version_id_col):
index a54097b03e09d71571cd1c26019981c786bcb699..247c5e7a80823dab3ece8183092e6897d3501f4a 100644 (file)
@@ -2505,7 +2505,8 @@ class PartialNullPKTest(fixtures.MappedTest):
         s.delete(t1)
         assert_raises_message(
             orm_exc.FlushError,
-            "Can't delete from table using NULL for primary key value",
+            "Can't delete from table t1 using NULL "
+            "for primary key value on column t1.col2",
             s.commit
         )