diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-19 18:17:25 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-19 18:17:25 -0400 |
| commit | cf14823e41c5e74b38d0bb7768139d04d47dfc4d (patch) | |
| tree | b2ecbce7d01967b7056215f0b40a8a62369f34fd /lib/sqlalchemy/orm/persistence.py | |
| parent | 91959122e0a12943e5ff9399024c65ad4d7489e1 (diff) | |
| parent | 28103e9a865860a46037ca82e634827f2329deb0 (diff) | |
| download | sqlalchemy-cf14823e41c5e74b38d0bb7768139d04d47dfc4d.tar.gz | |
Merge branch 'master' into ticket_3100
Diffstat (limited to 'lib/sqlalchemy/orm/persistence.py')
| -rw-r--r-- | lib/sqlalchemy/orm/persistence.py | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index 9c0008925..a4e14d92d 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -447,29 +447,19 @@ def _collect_update_commands(uowtransaction, table, states_to_update): history = state.manager[propkey].impl.get_history( state, state_dict, attributes.PASSIVE_OFF) - if row_switch and not history.deleted and history.added: - # row switch present. convert a row that thought - # it would be an INSERT into an UPDATE, by removing - # the PK value from the SET clause and instead putting - # it in the WHERE clause. - del params[col.key] - pk_params[col._label] = history.added[0] - elif history.added: - # we're updating the PK value. - assert history.deleted, ( - "New PK value without an old one not " - "possible for an UPDATE") - # check if an UPDATE of the PK value - # has already occurred as a result of ON UPDATE CASCADE. - # If so, use the new value to locate the row. - if ("pk_cascaded", state, col) in uowtransaction.attributes: + if history.added: + if not history.deleted or \ + ("pk_cascaded", state, col) in uowtransaction.attributes: pk_params[col._label] = history.added[0] + params.pop(col.key, None) else: # else, use the old value to locate the row pk_params[col._label] = history.deleted[0] + params[col.key] = history.added[0] else: pk_params[col._label] = history.unchanged[0] + if params or value_params: if None in pk_params.values(): raise orm_exc.FlushError( |
