From bad4493842caeba312403efb143144a91e562311 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 12 Sep 2010 12:37:43 -0400 Subject: - Slight improvement to the behavior of "passive_updates=False" when placed only on the many-to-one side of a relationship; documentation has been clarified that passive_updates=False should really be on the one-to-many side. - Placing passive_deletes=True on a many-to-one emits a warning, since you probably intended to put it on the one-to-many side. --- lib/sqlalchemy/orm/dependency.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/sqlalchemy/orm/dependency.py') diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 376afd88d..662cfc67b 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -734,7 +734,12 @@ class DetectKeySwitch(DependencyProcessor): def per_property_preprocessors(self, uow): if self.prop._reverse_property: - return + if self.passive_updates: + return + else: + if False in (prop.passive_updates for \ + prop in self.prop._reverse_property): + return uow.register_preprocessor(self, False) @@ -797,14 +802,12 @@ class DetectKeySwitch(DependencyProcessor): if switchers: # if primary key values have actually changed somewhere, perform # a linear search through the UOW in search of a parent. - # note that this handler isn't used if the many-to-one - # relationship has a backref. for state in uowcommit.session.identity_map.all_states(): if not issubclass(state.class_, self.parent.class_): continue dict_ = state.dict - related = dict_.get(self.key) - if related is not None: + related = state.get_impl(self.key).get(state, dict_, passive=self.passive_updates) + if related is not attributes.PASSIVE_NO_RESULT and related is not None: related_state = attributes.instance_state(dict_[self.key]) if related_state in switchers: uowcommit.register_object(state, -- cgit v1.2.1