mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-02 13:59:02 -04:00
Merge branch 'master' into ticket_3100
Conflicts: lib/sqlalchemy/orm/persistence.py
This commit is contained in:
@@ -494,12 +494,12 @@ def _collect_update_commands(
|
||||
params[col.key] = history.added[0]
|
||||
else:
|
||||
pk_params[col._label] = history.unchanged[0]
|
||||
if pk_params[col._label] is None:
|
||||
raise orm_exc.FlushError(
|
||||
"Can't update table %s using NULL for primary "
|
||||
"key value on column %s" % (table, col))
|
||||
|
||||
if params or value_params:
|
||||
if None in pk_params.values():
|
||||
raise orm_exc.FlushError(
|
||||
"Can't update table using NULL for primary "
|
||||
"key value")
|
||||
params.update(pk_params)
|
||||
yield (
|
||||
state, state_dict, params, mapper,
|
||||
|
||||
@@ -2479,7 +2479,8 @@ class PartialNullPKTest(fixtures.MappedTest):
|
||||
t1.col2 = 5
|
||||
assert_raises_message(
|
||||
orm_exc.FlushError,
|
||||
"Can't update table using NULL for primary key value",
|
||||
"Can't update table t1 using NULL for primary "
|
||||
"key value on column t1.col2",
|
||||
s.commit
|
||||
)
|
||||
|
||||
@@ -2492,7 +2493,8 @@ class PartialNullPKTest(fixtures.MappedTest):
|
||||
t1.col3 = 'hi'
|
||||
assert_raises_message(
|
||||
orm_exc.FlushError,
|
||||
"Can't update table using NULL for primary key value",
|
||||
"Can't update table t1 using NULL for primary "
|
||||
"key value on column t1.col2",
|
||||
s.commit
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user