From ca73fbab87d271ed9e63f8f4f0d13036ac46279a Mon Sep 17 00:00:00 2001 From: Jason Kirtland Date: Thu, 1 Nov 2007 16:36:50 +0000 Subject: [PATCH] Fixed truth-evaluation of mapped objects (part of [ticket:676] --- lib/sqlalchemy/orm/attributes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 1855a24b02..189cd52ee0 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -689,7 +689,9 @@ class InstanceDict(UserDict.UserDict): def __getitem__(self, key): state = self.data[key] - o = state.obj() or state._check_resurrect(self) + o = state.obj() + if o is None: + o = state._check_resurrect(self) if o is None: raise KeyError, key return o @@ -697,7 +699,9 @@ class InstanceDict(UserDict.UserDict): def __contains__(self, key): try: state = self.data[key] - o = state.obj() or state._check_resurrect(self) + o = state.obj() + if o is None: + o = state._check_resurrect(self) except KeyError: return False return o is not None -- 2.47.3