summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-02-05 19:16:10 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-02-05 19:16:10 +0000
commitb69cbec1355a0eef435f651aeabe3eddce2c3ce9 (patch)
treec3129ae9c5ecad63e04e220ca6ff6cba9e4a9e4c /lib
parent15fd2f79b85b6ee9e8165cd353e922500c907c87 (diff)
downloadsqlalchemy-b69cbec1355a0eef435f651aeabe3eddce2c3ce9.tar.gz
- Slight improvement to the fix for [ticket:1362] to not issue
needless updates of the primary key column during a so-called "row switch" operation, i.e. add + delete of two objects with the same PK.
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/mapper.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 941c303d7..2bdf2b847 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -1408,19 +1408,18 @@ class Mapper(object):
params[col.key] = prop.get_col_value(col, history.added[0])
if col in pks:
- # if passive_updates and sync detected this was a
- # pk->pk sync, use the new value to locate the row,
- # since the DB would already have set this
- if ("pk_cascaded", state, col) in \
- uowtransaction.attributes:
- params[col._label] = \
- prop.get_col_value(col, history.added[0])
- hasdata = True
-
- elif history.deleted:
- # PK is changing - use the old value to locate the row
- params[col._label] = \
- prop.get_col_value(col, history.deleted[0])
+ if history.deleted:
+ # if passive_updates and sync detected this was a
+ # pk->pk sync, use the new value to locate the row,
+ # since the DB would already have set this
+ if ("pk_cascaded", state, col) in \
+ uowtransaction.attributes:
+ params[col._label] = \
+ prop.get_col_value(col, history.added[0])
+ else:
+ # use the old value to locate the row
+ params[col._label] = \
+ prop.get_col_value(col, history.deleted[0])
hasdata = True
else:
# row switch logic can reach us here