summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/state.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/state.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/state.py')
-rw-r--r--lib/sqlalchemy/orm/state.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py
index 4d9fa5ade..f09c59763 100644
--- a/lib/sqlalchemy/orm/state.py
+++ b/lib/sqlalchemy/orm/state.py
@@ -1,7 +1,7 @@
from sqlalchemy.util import EMPTY_SET
import weakref
from sqlalchemy import util
-from sqlalchemy.orm.attributes import PASSIVE_NORESULT, PASSIVE_OFF, NEVER_SET, NO_VALUE, manager_of_class, ATTR_WAS_SET
+from sqlalchemy.orm.attributes import PASSIVE_NO_RESULT, PASSIVE_OFF, NEVER_SET, NO_VALUE, manager_of_class, ATTR_WAS_SET
from sqlalchemy.orm import attributes
from sqlalchemy.orm import interfaces
@@ -108,13 +108,13 @@ class InstanceState(object):
attribute.
returns None if passive is not PASSIVE_OFF and the getter returns
- PASSIVE_NORESULT.
+ PASSIVE_NO_RESULT.
"""
impl = self.get_impl(key)
dict_ = self.dict
x = impl.get(self, dict_, passive=passive)
- if x is PASSIVE_NORESULT:
+ if x is PASSIVE_NO_RESULT:
return None
elif hasattr(impl, 'get_collection'):
return impl.get_collection(self, dict_, x, passive=passive)
@@ -176,12 +176,16 @@ class InstanceState(object):
self.dict.pop(key, None)
self.callables[key] = callable_
- def __call__(self):
+ def __call__(self, **kw):
"""__call__ allows the InstanceState to act as a deferred
callable for loading expired attributes, which is also
serializable (picklable).
"""
+
+ if kw.get('passive') is attributes.PASSIVE_NO_FETCH:
+ return attributes.PASSIVE_NO_RESULT
+
unmodified = self.unmodified
class_manager = self.manager
class_manager.deferred_scalar_loader(self, [