summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/identity.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-08-07 21:14:32 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-08-07 21:14:32 +0000
commit7b019f3d49cb2e4340e4c2029e9841af0153b2e6 (patch)
tree39c43e82b2a3bff721ec48e197b62e66c6e0f8e6 /lib/sqlalchemy/orm/identity.py
parent54dd8b851b8378419594b6a629c30d9b7b47b7c7 (diff)
downloadsqlalchemy-7b019f3d49cb2e4340e4c2029e9841af0153b2e6.tar.gz
- renamed PASSIVE_NORESULT to PASSIVE_NO_RESULT
- renamed PASSIVE_NO_CALLABLES to PASSIVE_NO_FETCH - passive now propagates all the way through lazy callables, all the way into query._get(), so that many-to-one lazy load can load the instance via the local session but not trigger any SQL if not available, fixes [ticket:1298] without messing up consistency of tests added in r6201 - many-to-one also handles returning PASSIVE_NO_RESULT for the "old" value thus eliminating the need for the previous value even if the new value is None - query._get() uses identity_map.get(), which has been changed to no longer raise KeyError, thus providing mythical time savings that didn't seem to make any difference in how fast the unit tests ran.
Diffstat (limited to 'lib/sqlalchemy/orm/identity.py')
-rw-r--r--lib/sqlalchemy/orm/identity.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/identity.py b/lib/sqlalchemy/orm/identity.py
index b7d4234f4..889b65ba7 100644
--- a/lib/sqlalchemy/orm/identity.py
+++ b/lib/sqlalchemy/orm/identity.py
@@ -141,10 +141,15 @@ class WeakInstanceDict(IdentityMap):
self._manage_removed_state(state)
def get(self, key, default=None):
- try:
- return self[key]
- except KeyError:
+ state = dict.get(self, key, default)
+ if state is default:
+ return default
+ o = state.obj()
+ if o is None:
+ o = state._is_really_none()
+ if o is None:
return default
+ return o
# Py2K
def items(self):