summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-12-08 23:44:22 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-12-08 23:44:22 +0000
commit121f701c36c155dadbf7b496a1207c5a8ba95650 (patch)
treedd807c69c3cf6a7030ec031c1eb51ee8c8f5383a
parent74102ffc296d3a472a655db4e53584a24b8004a4 (diff)
downloadsqlalchemy-121f701c36c155dadbf7b496a1207c5a8ba95650.tar.gz
- Fixed bug in query.update() when passing Cls.attribute
as keys in the value dict and using synchronize_session='expire'. [ticket:1436]
-rw-r--r--CHANGES4
-rw-r--r--lib/sqlalchemy/orm/query.py2
-rw-r--r--test/orm/test_query.py4
3 files changed, 9 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 525a9112f..3cee14b5a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -59,6 +59,10 @@ CHANGES
combinations of reflected and non-reflected types to work
with 0.5 style type reflection, such as PGText/Text (note 0.6
reflects types as their generic versions). [ticket:1556]
+
+ - Fixed bug in query.update() when passing Cls.attribute
+ as keys in the value dict and using synchronize_session='expire'.
+ [ticket:1436]
- sql
- Fixed bug in two-phase transaction whereby commit() method
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index a3c78940b..e9677b8c9 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -1783,7 +1783,7 @@ class Query(object):
for primary_key in matched_rows:
identity_key = target_mapper.identity_key_from_primary_key(list(primary_key))
if identity_key in session.identity_map:
- session.expire(session.identity_map[identity_key], values.keys())
+ session.expire(session.identity_map[identity_key], [expression._column_as_key(k) for k in values])
for ext in session.extensions:
ext.after_bulk_update(session, self, context, result)
diff --git a/test/orm/test_query.py b/test/orm/test_query.py
index c7dce9332..529f7bb84 100644
--- a/test/orm/test_query.py
+++ b/test/orm/test_query.py
@@ -2967,6 +2967,10 @@ class UpdateDeleteTest(_base.MappedTest):
eq_([john.age, jack.age, jill.age, jane.age], [25,27,19,27])
eq_(sess.query(User.age).order_by(User.id).all(), zip([25,27,19,27]))
+ sess.query(User).filter(User.age == 25).update({User.age: User.age - 10}, synchronize_session='expire')
+ eq_([john.age, jack.age, jill.age, jane.age], [15,27,19,27])
+ eq_(sess.query(User.age).order_by(User.id).all(), zip([15,27,19,27]))
+
@testing.resolve_artifact_names
def test_update_with_bindparams(self):