summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/events.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-02-14 11:39:44 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2017-03-15 17:22:59 -0400
commit2bfe19152d49b969acdc4607bf7c33727f796f5a (patch)
tree0f71aa7ac14459bb03f1b6ced1c66741d90a9232 /lib/sqlalchemy/orm/events.py
parentb5b6e9574854fd9784d7c26e2c585a3ff5ae4cb6 (diff)
downloadsqlalchemy-2bfe19152d49b969acdc4607bf7c33727f796f5a.tar.gz
Don't mutate old collection on bulk replace
For a bulk replace, assume the old collection is no longer useful to the attribute system and only send the removal events, not actually mutated the collection. this changes behavior significantly and also means that dispose_collection now receives the old collection intact. Change-Id: Ic2685c85438191f07797d9ef97833a2cfdc4fcc2 Fixes: #3913
Diffstat (limited to 'lib/sqlalchemy/orm/events.py')
-rw-r--r--lib/sqlalchemy/orm/events.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py
index d2ccec432..ceeb31e9c 100644
--- a/lib/sqlalchemy/orm/events.py
+++ b/lib/sqlalchemy/orm/events.py
@@ -2124,8 +2124,12 @@ class AttributeEvents(event.Events):
u1.addresses = [a2, a3] # <- old collection is disposed
- The mechanics of the event will typically include that the given
- collection is empty, even if it stored objects while being replaced.
+ The old collection received will contain its previous contents.
+
+ .. versionchanged:: 1.2 The collection passed to
+ :meth:`.AttributeEvents.dispose_collection` will now have its
+ contents before the dispose intact; previously, the collection
+ would be empty.
.. versionadded:: 1.0.0 the :meth:`.AttributeEvents.init_collection`
and :meth:`.AttributeEvents.dispose_collection` events supersede