diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-07 21:14:32 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-07 21:14:32 +0000 |
commit | 7b019f3d49cb2e4340e4c2029e9841af0153b2e6 (patch) | |
tree | 39c43e82b2a3bff721ec48e197b62e66c6e0f8e6 /lib/sqlalchemy/orm/identity.py | |
parent | 54dd8b851b8378419594b6a629c30d9b7b47b7c7 (diff) | |
download | sqlalchemy-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.py | 11 |
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): |