--- /dev/null
+.. change::
+ :tags: orm
+ :tickets: 4642
+
+ Remove the deprecated loader options ``joinedload_all``, ``subqueryload_all``,
+ ``lazyload_all``, ``selectinload_all``. The normal version with method chaining
+ should be used in their place.
.. autofunction:: eagerload
-.. autofunction:: eagerload_all
-
.. autofunction:: immediateload
.. autofunction:: joinedload
-.. autofunction:: joinedload_all
-
.. autofunction:: lazyload
.. autoclass:: Load
.. autofunction:: selectinload
-.. autofunction:: selectinload_all
-
.. autofunction:: subqueryload
-
-.. autofunction:: subqueryload_all
from sqlalchemy import String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import backref
-from sqlalchemy.orm import joinedload_all
+from sqlalchemy.orm import joinedload
from sqlalchemy.orm import relationship
from sqlalchemy.orm import Session
from sqlalchemy.orm.collections import attribute_mapped_collection
node = (
session.query(TreeNode)
.options(
- joinedload_all("children", "children", "children", "children")
+ joinedload("children")
+ .joinedload("children")
+ .joinedload("children")
+ .joinedload("children")
)
.filter(TreeNode.name == "rootnode")
.first()
joinedload = strategy_options.joinedload._unbound_fn
-joinedload_all = strategy_options.joinedload._unbound_all_fn
contains_eager = strategy_options.contains_eager._unbound_fn
defer = strategy_options.defer._unbound_fn
undefer = strategy_options.undefer._unbound_fn
with_expression = strategy_options.with_expression._unbound_fn
load_only = strategy_options.load_only._unbound_fn
lazyload = strategy_options.lazyload._unbound_fn
-lazyload_all = strategy_options.lazyload_all._unbound_all_fn
subqueryload = strategy_options.subqueryload._unbound_fn
-subqueryload_all = strategy_options.subqueryload_all._unbound_all_fn
selectinload = strategy_options.selectinload._unbound_fn
-selectinload_all = strategy_options.selectinload_all._unbound_all_fn
immediateload = strategy_options.immediateload._unbound_fn
noload = strategy_options.noload._unbound_fn
raiseload = strategy_options.raiseload._unbound_fn
return joinedload(*args, **kwargs)
-def eagerload_all(*args, **kwargs):
- """A synonym for :func:`joinedload_all()`"""
- return joinedload_all(*args, **kwargs)
-
-
contains_alias = public_factory(AliasOption, ".orm.contains_alias")
return _UnboundLoad._from_keys(_UnboundLoad.joinedload, keys, False, kw)
-@joinedload._add_unbound_all_fn
-def joinedload_all(*keys, **kw):
- return _UnboundLoad._from_keys(_UnboundLoad.joinedload, keys, True, kw)
-
-
@loader_option()
def subqueryload(loadopt, attr):
"""Indicate that the given attribute should be loaded using
return _UnboundLoad._from_keys(_UnboundLoad.subqueryload, keys, False, {})
-@subqueryload._add_unbound_all_fn
-def subqueryload_all(*keys):
- return _UnboundLoad._from_keys(_UnboundLoad.subqueryload, keys, True, {})
-
-
@loader_option()
def selectinload(loadopt, attr):
"""Indicate that the given attribute should be loaded using
return _UnboundLoad._from_keys(_UnboundLoad.selectinload, keys, False, {})
-@selectinload._add_unbound_all_fn
-def selectinload_all(*keys):
- return _UnboundLoad._from_keys(_UnboundLoad.selectinload, keys, True, {})
-
-
@loader_option()
def lazyload(loadopt, attr):
"""Indicate that the given attribute should be loaded using "lazy"
return _UnboundLoad._from_keys(_UnboundLoad.lazyload, keys, False, {})
-@lazyload._add_unbound_all_fn
-def lazyload_all(*keys):
- return _UnboundLoad._from_keys(_UnboundLoad.lazyload, keys, True, {})
-
-
@loader_option()
def immediateload(loadopt, attr):
"""Indicate that the given attribute should be loaded using
from sqlalchemy.orm import identity
from sqlalchemy.orm import instrumentation
from sqlalchemy.orm import joinedload
-from sqlalchemy.orm import joinedload_all
from sqlalchemy.orm import mapper
from sqlalchemy.orm import PropComparator
from sqlalchemy.orm import relationship
*options
)
- def test_option_against_nonexistent_twolevel_all(self):
- self._mapper_fixture_one()
- Item = self.classes.Item
- with testing.expect_deprecated(
- r"The joinedload_all\(\) function is deprecated, and "
- "will be removed in a future release. "
- r"Please use method chaining with joinedload\(\)"
- ):
- self._assert_eager_with_entity_exception(
- [Item],
- (joinedload_all("keywords.foo"),),
- 'Can\'t find property named \\"foo\\" on mapped class '
- "Keyword->keywords in this Query.",
- )
-
- def test_all_path_vs_chained(self):
- self._mapper_fixture_one()
- User = self.classes.User
- Order = self.classes.Order
- Item = self.classes.Item
-
- with testing.expect_deprecated(
- r"The joinedload_all\(\) function is deprecated, and "
- "will be removed in a future release. "
- r"Please use method chaining with joinedload\(\)"
- ):
- l1 = joinedload_all("orders.items.keywords")
-
- sess = Session()
- q = sess.query(User)
- self._assert_path_result(
- l1,
- q,
- [
- (User, "orders"),
- (User, "orders", Order, "items"),
- (User, "orders", Order, "items", Item, "keywords"),
- ],
- )
-
- l2 = joinedload("orders").joinedload("items").joinedload("keywords")
- self._assert_path_result(
- l2,
- q,
- [
- (User, "orders"),
- (User, "orders", Order, "items"),
- (User, "orders", Order, "items", Item, "keywords"),
- ],
- )
-
def test_subqueryload_mapper_order_by(self):
users, User, Address, addresses = (
self.tables.users,