summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-10-06 12:46:02 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-10-06 12:46:02 -0400
commitab59e3e1135e1c5b59d19a54114163119d5ab1a4 (patch)
tree65c9c88fc5bfb4b6841e70730b231d5904266917 /lib/sqlalchemy
parentb7b242dbb5709aab76d1a035db3d5a72d079740c (diff)
downloadsqlalchemy-ab59e3e1135e1c5b59d19a54114163119d5ab1a4.tar.gz
- [bug] Continuing [ticket:2566] regarding extra
state post-flush due to event listeners; any states that are marked as "dirty" from an attribute perspective, usually via column-attribute set events within after_insert(), after_update(), etc., will get the "history" flag reset in all cases, instead of only those instances that were part of the flush. This has the effect that this "dirty" state doesn't carry over after the flush and won't result in UPDATE statements. A warning is emitted to this effect; the set_committed_state() method can be used to assign attributes on objects without producing history events. [ticket:2582]
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/session.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index dcbd6ba7e..70d3bc0bb 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -1841,6 +1841,21 @@ class Session(_SessionClassMethods):
flush_context.finalize_flush_changes()
+ if not objects and self.identity_map._modified:
+ len_ = len(self.identity_map._modified)
+
+ statelib.InstanceState._commit_all_states(
+ [(state, state.dict) for state in
+ self.identity_map._modified],
+ instance_dict=self.identity_map)
+ util.warn("Attribute history events accumulated on %d "
+ "previously clean instances "
+ "within inner-flush event handlers have been reset, "
+ "and will not result in database updates. "
+ "Consider using set_committed_value() within "
+ "inner-flush event handlers to avoid this warning."
+ % len_)
+
# useful assertions:
#if not objects:
# assert not self.identity_map._modified