From 9e20d410212296517f8dffd2531d55fee196635b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 8 Dec 2021 14:19:11 -0500 Subject: Removals: strings for join(), loader_options(). * The :meth:`_orm.Query.join` method no longer accepts strings for relationship names; the long-documented approach of using ``Class.attrname`` for join targets is now standard. * Loader options no longer accept strings for attribute names. The long-documented approach of using ``Class.attrname`` for loader option targets is now standard. It is hoped that a subsequent commit can refactor loader options to no longer need "UnboundLoad" for most cases. Change-Id: If4629882c40523dccbf4459256bf540fb468b618 References: #6986 --- lib/sqlalchemy/sql/coercions.py | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index 07da49c4e..38eed4d2a 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -610,20 +610,6 @@ class OnClauseImpl(_CoerceLiterals, _ColumnCoercions, RoleImpl): _coerce_consts = True - def _implicit_coercions( - self, original_element, resolved, argname=None, legacy=False, **kw - ): - if legacy and isinstance(resolved, str): - return resolved - else: - return super(OnClauseImpl, self)._implicit_coercions( - original_element, - resolved, - argname=argname, - legacy=legacy, - **kw - ) - def _text_coercion(self, element, argname=None, legacy=False): if legacy and isinstance(element, str): util.warn_deprecated_20( @@ -925,9 +911,8 @@ class JoinTargetImpl(RoleImpl): _skip_clauseelement_for_target_match = True - def _literal_coercion(self, element, legacy=False, **kw): - if isinstance(element, str): - return element + def _literal_coercion(self, element, argname=None, **kw): + self._raise_for_expected(element, argname) def _implicit_coercions( self, original_element, resolved, argname=None, legacy=False, **kw @@ -937,14 +922,6 @@ class JoinTargetImpl(RoleImpl): # #6550, unless JoinTargetImpl._skip_clauseelement_for_target_match # were set to False. return original_element - elif legacy and isinstance(resolved, str): - util.warn_deprecated_20( - "Using strings to indicate relationship names in " - "Query.join() is deprecated and will be removed in " - "SQLAlchemy 2.0. Please use the class-bound attribute " - "directly." - ) - return resolved elif legacy and isinstance(resolved, roles.WhereHavingRole): return resolved elif legacy and resolved._is_select_statement: -- cgit v1.2.1