summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-10-14 15:00:49 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-10-14 15:00:49 +0000
commit3bdf56dc7d4624b8b1b07c9e49e945dfe6a14e62 (patch)
treefdeeea9d92f47da83668fee449f1c93d2df6688e /lib/sqlalchemy/sql
parent34f8622b687f33dadff4f8e81532b3f4050246f4 (diff)
parent348260943a52ddd7ee3388eaac8e05da3794958b (diff)
downloadsqlalchemy-3bdf56dc7d4624b8b1b07c9e49e945dfe6a14e62.tar.gz
Merge "Deprecate strings indicating attribute names"
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/coercions.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py
index 558ced8bd..9b3acf5ad 100644
--- a/lib/sqlalchemy/sql/coercions.py
+++ b/lib/sqlalchemy/sql/coercions.py
@@ -352,7 +352,7 @@ class _CoerceLiterals(object):
if self._coerce_star and element == "*":
return elements.ColumnClause("*", is_literal=True)
else:
- return self._text_coercion(element, argname)
+ return self._text_coercion(element, argname, **kw)
if self._coerce_consts:
if element is None:
@@ -528,6 +528,32 @@ 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(
+ "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 element
+
+ return super(OnClauseImpl, self)._text_coercion(element, argname)
+
def _post_coercion(self, resolved, original_element=None, **kw):
# this is a hack right now as we want to use coercion on an
# ORM InstrumentedAttribute, but we want to return the object
@@ -802,7 +828,15 @@ class JoinTargetImpl(RoleImpl):
):
if isinstance(original_element, roles.JoinTargetRole):
return original_element
- elif legacy and isinstance(resolved, (str, roles.WhereHavingRole)):
+ 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:
util.warn_deprecated(