summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-09-01 17:01:55 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-09-01 17:01:55 +0000
commit35e2f6680b17dcf0f65b4e392d2504bfe8000efb (patch)
tree6b155074e80a0972efad5e993ecf33ec497954bc /lib/sqlalchemy/orm
parent005603e2fb198c3f3328fa555e82a334f0f89d52 (diff)
downloadsqlalchemy-35e2f6680b17dcf0f65b4e392d2504bfe8000efb.tar.gz
futher fix to the "orphan state" idea. to avoid setting tons of
"hasparent" flags on objects as they are loaded, both from lazy and eager loads, the "orphan" check now uses an "optimistic" flag to determine the result if no "hasparent" flag is found for a particular relationship on an instance. if the instance has an _instance_key and therefore was loaded from the database, it is assumed to not be an orphan unless a "False" hasparent flag has been set. if the instance does not have an _instance_key and is therefore transient/pending, it is assumed to be an orphan unless a "True" hasparent flag has been set.
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/mapper.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 5fed12188..21d4c6e36 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -141,8 +141,9 @@ class Mapper(object):
#self.compile()
def _is_orphan(self, obj):
+ optimistic = hasattr(obj, '_instance_key')
for (key,klass) in self.delete_orphans:
- if not getattr(klass, key).hasparent(obj):
+ if not getattr(klass, key).hasparent(obj, optimistic=optimistic):
return True
else:
return False