Small improvement on FlushError can't delete error message

Output in the error message the table name and the column name.
This commit is contained in:
Paulo Bu
2014-11-05 13:15:08 +01:00
parent edec583b45
commit ea637cef2d
2 changed files with 4 additions and 3 deletions
+2 -2
View 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):
+2 -1
View 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
)