diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-11-17 19:34:47 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-11-17 19:34:47 -0500 |
commit | 1321a0c2b95ce4381157d0633f2d292a1d286151 (patch) | |
tree | 90206e66436c6e79ead76b37a6cae476417329f4 /lib/sqlalchemy/orm/unitofwork.py | |
parent | d3ca4156495af556e448a8d3f6d5884d08ab2f9b (diff) | |
download | sqlalchemy-1321a0c2b95ce4381157d0633f2d292a1d286151.tar.gz |
- establish a consistent pattern of behavior along o2m, m2m, and m2o relationships
when "save-update" cascade is disabled, or the target object is otherwise not
present in the session, and collection/scalar changes have taken place. A warning
is emitted describing the type of operation, the target reference, and the relationship
description, stating that the operation will not take place. The operation then doesn't
take place. [ticket:1973]
- clean up test_cascade a little bit, remove cruft
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r-- | lib/sqlalchemy/orm/unitofwork.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index 673591e8e..8f7475c4b 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -176,9 +176,14 @@ class UOWTransaction(object): self.presort_actions[key] = Preprocess(processor, fromparent) def register_object(self, state, isdelete=False, - listonly=False, cancel_delete=False): + listonly=False, cancel_delete=False, + operation=None, prop=None): if not self.session._contains_state(state): - return + if not state.deleted and operation is not None: + util.warn("Object %s not in session, %s operation " + "along '%s' will not proceed" % + (mapperutil.state_str(state), operation, prop)) + return False if state not in self.states: mapper = _state_mapper(state) @@ -191,7 +196,8 @@ class UOWTransaction(object): else: if not listonly and (isdelete or cancel_delete): self.states[state] = (isdelete, False) - + return True + def issue_post_update(self, state, post_update_cols): mapper = state.manager.mapper.base_mapper states, cols = self.post_update_states[mapper] |