diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-28 17:57:48 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-08-28 17:57:48 -0400 |
| commit | fa5522547150687c9b3cd41d28df08ab0512b5b2 (patch) | |
| tree | 7190563b7a1c282a6b2bde3414a58a54e5e2ee56 /lib/sqlalchemy | |
| parent | 9f4caf97b0172065fdf0f6da8f073d72abf8fd84 (diff) | |
| download | sqlalchemy-fa5522547150687c9b3cd41d28df08ab0512b5b2.tar.gz | |
- Made a small adjustment to the mechanics of lazy loading,
such that it has less chance of interfering with a joinload() in the
very rare circumstance that an object points to itself; in this
scenario, the object refers to itself while loading its attributes
which can cause a mixup between loaders. The use case of
"object points to itself" is not fully supported, but the fix also
removes some overhead so for now is part of testing.
fixes #3145
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/util.py | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index c3edbf6e6..2d8a81f0a 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -634,7 +634,7 @@ class LazyLoader(AbstractRelationshipLoader): LoadLazyAttribute(key), key) return set_lazy_callable, None, None - else: + elif context.populate_existing or mapper.always_refresh: def reset_for_lazy_callable(state, dict_, row): # we are the primary manager for this attribute on # this class - reset its @@ -647,6 +647,9 @@ class LazyLoader(AbstractRelationshipLoader): state._reset(dict_, key) return reset_for_lazy_callable, None, None + else: + return None, None, None + class LoadLazyAttribute(object): diff --git a/lib/sqlalchemy/testing/util.py b/lib/sqlalchemy/testing/util.py index fc8390a79..7b3f721a6 100644 --- a/lib/sqlalchemy/testing/util.py +++ b/lib/sqlalchemy/testing/util.py @@ -203,5 +203,7 @@ class adict(dict): except KeyError: return dict.__getattribute__(self, key) - def get_all(self, *keys): + def __call__(self, *keys): return tuple([self[key] for key in keys]) + + get_all = __call__ |
