- changed milestone to 0.7.0
inconsistent treatment of collection flushes
Issue #1973
resolved
consider generating a suite of tests for collection append/delete where the target is not present in the session. establish consistent behavior for o2m and m2m, or at least cover it. This will probably be pushed to 0.7 since it implies a behavioral change.
diff -r d3ca4156495af556e448a8d3f6d5884d08ab2f9b lib/sqlalchemy/orm/dependency.py
--- a/lib/sqlalchemy/orm/dependency.py Wed Nov 17 10:55:10 2010 -0500
+++ b/lib/sqlalchemy/orm/dependency.py Wed Nov 17 15:36:36 2010 -0500
@@ -903,7 +903,7 @@
if not self.cascade.delete_orphan:
return
-
+
# check for child items removed from the collection
# if delete_orphan check is turned on.
for state in states:
@@ -975,7 +975,8 @@
for child in history.added:
if child is None or \
(processed is not None and
- (state, child) in processed):
+ # WHY NOT HERE ?
+ (state, child) in processed) :
continue
associationrow = {}
self._synchronize(state,
@@ -987,7 +988,11 @@
if child is None or \
(processed is not None and
(state, child) in processed) or \
- not uowcommit.session._contains_state(child):
+ (
+ # ...BUT HERE ? ALSO NO TEST COVERAGE !
+ # HOW ABOUT O2M ?
+ not uowcommit.session._contains_state(child):
+ )
continue
associationrow = {}
self._synchronize(state,
Comments (4)
-
reporter -
reporter Big one. test_cascade is a huge series of tests. The patch as it stands so far is at http://bitbucket.org/zzzeek/ticket_1973.
-
reporter - changed status to resolved
diff:@2336b1cebfcb2f304e09cbc2a0e8bb3fb3a9ceeb:bb9c16bef2da2f95497f3829e0b79207e459b30a
-
reporter - removed milestone
Removing milestone: 0.7.0 (automated comment)
- Log in to comment
in the case of o2m, the target item requires the INSERT/UPDATE, so isn't in the session and is ignored. For consistency we should go with as few operations proceeding as possible for items not in the session. The attached patch is an experimental approach that emits warnings every time an object is ignored.