summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-10-14 18:06:13 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-10-14 18:06:13 +0000
commitb56ed8ccb84fb4e173930696ed052acdff5cc3ad (patch)
tree2fa476aca78bf83355d3b3bbd50ff7179d87330e /lib
parentdda6a5f5a88a04d34b973cfb7c0f6d89d4b0e44f (diff)
downloadsqlalchemy-b56ed8ccb84fb4e173930696ed052acdff5cc3ad.tar.gz
- backref remove object operation doesn't fail if the other-side
collection doesn't contain the item, supports noload collections [ticket:813]
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/attributes.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 714b00376..4b64d52e3 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -520,7 +520,13 @@ class GenericBackrefExtension(interfaces.AttributeExtension):
if oldchild is child:
return
if oldchild is not None:
- getattr(oldchild.__class__, self.key).impl.remove(oldchild._state, obj, initiator)
+ # With lazy=None, there's no guarantee that the full collection is
+ # present when updating via a backref.
+ impl = getattr(oldchild.__class__, self.key).impl
+ try:
+ impl.remove(oldchild._state, obj, initiator)
+ except (ValueError, KeyError, IndexError):
+ pass
if child is not None:
getattr(child.__class__, self.key).impl.append(child._state, obj, initiator)