diff options
Diffstat (limited to 'lib/sqlalchemy/sql/functions.py')
-rw-r--r-- | lib/sqlalchemy/sql/functions.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py index c7ddcc18a..6d331910d 100644 --- a/lib/sqlalchemy/sql/functions.py +++ b/lib/sqlalchemy/sql/functions.py @@ -607,6 +607,13 @@ class Function(FunctionElement): ("type", InternalTraversal.dp_type), ] + @util.deprecated_params( + bind=( + "2.0", + "The :paramref:`_sql.text.bind` argument is deprecated and " + "will be removed in SQLAlchemy 2.0.", + ), + ) def __init__(self, name, *clauses, **kw): """Construct a :class:`.Function`. @@ -616,11 +623,20 @@ class Function(FunctionElement): """ self.packagenames = kw.pop("packagenames", None) or () self.name = name - self._bind = kw.get("bind", None) + + self._bind = self._get_bind(kw) self.type = sqltypes.to_instance(kw.get("type_", None)) FunctionElement.__init__(self, *clauses, **kw) + def _get_bind(self, kw): + if "bind" in kw: + util.warn_deprecated_20( + "The Function.bind argument is deprecated and " + "will be removed in SQLAlchemy 2.0.", + ) + return kw["bind"] + def _bind_param(self, operator, obj, type_=None): return BindParameter( self.name, @@ -760,7 +776,7 @@ class GenericFunction(util.with_metaclass(_GenericMeta, Function)): ] self._has_args = self._has_args or bool(parsed_args) self.packagenames = () - self._bind = kwargs.get("bind", None) + self._bind = self._get_bind(kwargs) self.clause_expr = ClauseList( operator=operators.comma_op, group_contents=True, *parsed_args ).self_group() @@ -794,7 +810,7 @@ class next_value(GenericFunction): assert isinstance( seq, schema.Sequence ), "next_value() accepts a Sequence object as input." - self._bind = kw.get("bind", None) + self._bind = self._get_bind(kw) self.sequence = seq def compare(self, other, **kw): |