From: Federico Caselli Date: Tue, 3 Mar 2020 21:32:19 +0000 (+0100) Subject: Remove the deprecated loader options X-Git-Tag: rel_1_4_0b1~489^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41001d5358549f89b7a4843b3421742b7e3adf3e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Remove the deprecated loader options 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. Fixes: #4642 Change-Id: I12eb4dfa7a86375911a570934ee662653d85d50a --- diff --git a/doc/build/changelog/unreleased_14/4642.rst b/doc/build/changelog/unreleased_14/4642.rst new file mode 100644 index 0000000000..cefdabbba4 --- /dev/null +++ b/doc/build/changelog/unreleased_14/4642.rst @@ -0,0 +1,7 @@ +.. 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. diff --git a/doc/build/orm/loading_relationships.rst b/doc/build/orm/loading_relationships.rst index 556759eebb..9da0dfd413 100644 --- a/doc/build/orm/loading_relationships.rst +++ b/doc/build/orm/loading_relationships.rst @@ -1258,14 +1258,10 @@ Relationship Loader API .. autofunction:: eagerload -.. autofunction:: eagerload_all - .. autofunction:: immediateload .. autofunction:: joinedload -.. autofunction:: joinedload_all - .. autofunction:: lazyload .. autoclass:: Load @@ -1276,8 +1272,4 @@ Relationship Loader API .. autofunction:: selectinload -.. autofunction:: selectinload_all - .. autofunction:: subqueryload - -.. autofunction:: subqueryload_all diff --git a/examples/adjacency_list/adjacency_list.py b/examples/adjacency_list/adjacency_list.py index 8cdd885403..fee0f413f6 100644 --- a/examples/adjacency_list/adjacency_list.py +++ b/examples/adjacency_list/adjacency_list.py @@ -5,7 +5,7 @@ from sqlalchemy import Integer 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 @@ -108,7 +108,10 @@ if __name__ == "__main__": node = ( session.query(TreeNode) .options( - joinedload_all("children", "children", "children", "children") + joinedload("children") + .joinedload("children") + .joinedload("children") + .joinedload("children") ) .filter(TreeNode.name == "rootnode") .first() diff --git a/lib/sqlalchemy/orm/__init__.py b/lib/sqlalchemy/orm/__init__.py index 05fcc3fc99..307f55ad0a 100644 --- a/lib/sqlalchemy/orm/__init__.py +++ b/lib/sqlalchemy/orm/__init__.py @@ -238,7 +238,6 @@ def clear_mappers(): 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 @@ -246,11 +245,8 @@ undefer_group = strategy_options.undefer_group._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 @@ -263,11 +259,6 @@ def eagerload(*args, **kwargs): 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") diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py index 4f7d996d4f..b7ccd7ff5a 100644 --- a/lib/sqlalchemy/orm/strategy_options.py +++ b/lib/sqlalchemy/orm/strategy_options.py @@ -1258,11 +1258,6 @@ def joinedload(*keys, **kw): 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 @@ -1301,11 +1296,6 @@ def subqueryload(*keys): 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 @@ -1345,11 +1335,6 @@ def selectinload(*keys): 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" @@ -1373,11 +1358,6 @@ def lazyload(*keys): 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 diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index bf04522349..1097af245c 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -25,7 +25,6 @@ from sqlalchemy.orm import foreign 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 @@ -1395,57 +1394,6 @@ class DeprecatedOptionAllTest(OptionsPathTest, _fixtures.FixtureTest): *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,