diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-24 19:11:01 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-24 19:11:01 -0400 |
commit | 1675811029553501bb23084604c64d974dfe739c (patch) | |
tree | 7e3c29f55c562aab06a48b6b4727f59156ed6722 /lib/sqlalchemy/orm/strategies.py | |
parent | 290a1596ce6f806aa6f25dd754cf0d2197f160ff (diff) | |
download | sqlalchemy-1675811029553501bb23084604c64d974dfe739c.tar.gz |
- To accomodate the fact that there are now two kinds of eager
loading available, the new names for eagerload() and
eagerload_all() are joinedload() and joinedload_all(). The
old names will remain as synonyms for the foreseeable future.
- The "lazy" flag on the relationship() function now accepts
a string argument for all kinds of loading: "select", "joined",
"subquery", "noload" and "dynamic", where the default is now
"select". The old values of True/
False/None still retain their usual meanings and will remain
as synonyms for the foreseeable future.
- Added documentation to tutorial,mapper doc, api docs
for subqueryload, subqueryload_all, and other options.
Diffstat (limited to 'lib/sqlalchemy/orm/strategies.py')
-rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 0665bdcb3..f4f3b5821 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -1125,28 +1125,34 @@ log.class_logger(EagerLoader) class EagerLazyOption(StrategizedOption): def __init__(self, key, lazy=True, chained=False, - propagate_to_loaders=True, - _strategy_cls=None + propagate_to_loaders=True ): super(EagerLazyOption, self).__init__(key) self.lazy = lazy self.chained = chained self.propagate_to_loaders = propagate_to_loaders - self.strategy_cls = _strategy_cls + self.strategy_cls = factory(lazy) def is_chained(self): return not self.lazy and self.chained def get_strategy_class(self): - if self.strategy_cls: - return self.strategy_cls - elif self.lazy: - return LazyLoader - elif self.lazy is False: - return EagerLoader - elif self.lazy is None: - return NoLoader - + return self.strategy_cls + +def factory(identifier): + if identifier is False or identifier == 'joined': + return EagerLoader + elif identifier is None or identifier == 'noload': + return NoLoader + elif identifier is False or identifier == 'select': + return LazyLoader + elif identifier == 'subquery': + return SubqueryLoader + else: + return LazyLoader + + + class EagerJoinOption(PropertyOption): def __init__(self, key, innerjoin, chained=False): |