From 45e6875752fcaf7d3a60907959ed9d154cca0d5d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 28 Jan 2012 14:33:29 -0500 Subject: - [bug] Fixed bug where "merge" cascade could mis-interpret an unloaded attribute, if the load_on_pending flag were used with relationship(). Thanks to Kent Bower for tests. [ticket:2374] --- lib/sqlalchemy/orm/unitofwork.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index 757deffef..3cd0f15eb 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -66,7 +66,10 @@ def track_cascade_events(descriptor, prop): not sess._contains_state(newvalue_state): sess._save_or_update_state(newvalue_state) - if oldvalue is not None and prop.cascade.delete_orphan: + if oldvalue is not None and \ + oldvalue is not attributes.PASSIVE_NO_RESULT and \ + prop.cascade.delete_orphan: + # possible to reach here with attributes.NEVER_SET ? oldvalue_state = attributes.instance_state(oldvalue) if oldvalue_state in sess._new and \ -- cgit v1.2.1