diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-10-29 12:38:42 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-10-30 20:22:13 -0400 |
| commit | 0718add3714451c1ae8ca00215ffb6c0fabdf366 (patch) | |
| tree | c472fbc4bb6052a87980ee93f5471fdff93e2338 /lib/sqlalchemy | |
| parent | 10851b002844fa4f9de7af92dbb15cb1133497eb (diff) | |
| download | sqlalchemy-0718add3714451c1ae8ca00215ffb6c0fabdf366.tar.gz | |
Deprecate bind args, execute() methods that were missed
in particular text(bind), DDL.execute().
Change-Id: Ie85ae9f61219182f5649f68e5f52b4923843199c
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/ddl.py | 17 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/elements.py | 7 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/functions.py | 22 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 7 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/warnings.py | 2 |
7 files changed, 54 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 10499975c..3819d1b9e 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -447,9 +447,6 @@ class Compiled(object): :param statement: :class:`_expression.ClauseElement` to be compiled. - :param bind: Optional Engine or Connection to compile this - statement against. - :param schema_translate_map: dictionary of schema names to be translated when forming the resultant SQL diff --git a/lib/sqlalchemy/sql/ddl.py b/lib/sqlalchemy/sql/ddl.py index 5f3074cdc..3bd831292 100644 --- a/lib/sqlalchemy/sql/ddl.py +++ b/lib/sqlalchemy/sql/ddl.py @@ -78,6 +78,14 @@ class DDLElement(roles.DDLRole, Executable, _DDLCompiles): self, multiparams, params, execution_options ) + @util.deprecated_20( + ":meth:`.DDL.execute`", + alternative="All statement execution in SQLAlchemy 2.0 is performed " + "by the :meth:`_engine.Connection.execute` method of " + ":class:`_engine.Connection`, " + "or in the ORM by the :meth:`.Session.execute` method of " + ":class:`.Session`.", + ) def execute(self, bind=None, target=None): """Execute this DDL immediately. @@ -149,7 +157,7 @@ class DDLElement(roles.DDLRole, Executable, _DDLCompiles): @_generative def execute_if(self, dialect=None, callable_=None, state=None): r"""Return a callable that will execute this - DDLElement conditionally. + :class:`_ddl.DDLElement` conditionally within an event handler. Used to provide a wrapper for event listening:: @@ -289,6 +297,13 @@ class DDL(DDLElement): __visit_name__ = "ddl" + @util.deprecated_params( + bind=( + "2.0", + "The :paramref:`_ddl.DDL.bind` argument is deprecated and " + "will be removed in SQLAlchemy 2.0.", + ), + ) def __init__(self, statement, context=None, bind=None): """Create a DDL statement. diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 00e28ac20..58eb7f41c 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -1568,6 +1568,13 @@ class TextClause( @classmethod @_document_text_coercion("text", ":func:`.text`", ":paramref:`.text.text`") + @util.deprecated_params( + bind=( + "2.0", + "The :paramref:`_sql.text.bind` argument is deprecated and " + "will be removed in SQLAlchemy 2.0.", + ), + ) def _create_text(cls, text, bind=None): r"""Construct a new :class:`_expression.TextClause` clause, representing 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): diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index d764002a6..36c7fccca 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -4331,6 +4331,9 @@ class MetaData(SchemaItem): A :class:`.Connectable` used to access the database; if None, uses the existing bind on this ``MetaData``, if any. + .. note:: the "bind" argument will be required in + SQLAlchemy 2.0. + :param schema: Optional, query and reflect tables from an alternate schema. If None, the schema associated with this :class:`_schema.MetaData` diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index fd8832400..3722e9ade 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -2815,6 +2815,13 @@ class GenerativeSelect(DeprecatedSelectBaseGenerations, SelectBase): _fetch_clause_options = None _for_update_arg = None + @util.deprecated_params( + bind=( + "2.0", + "The :paramref:`_sql.select.bind` argument is deprecated and " + "will be removed in SQLAlchemy 2.0.", + ), + ) def __init__( self, _label_style=LABEL_STYLE_NONE, diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py index f3eb2b135..cf88a70c4 100644 --- a/lib/sqlalchemy/testing/warnings.py +++ b/lib/sqlalchemy/testing/warnings.py @@ -66,6 +66,8 @@ def setup_filters(): r"The MetaData.bind argument is deprecated", r"The ``bind`` argument for schema methods that invoke SQL ", r"The Executable.bind attribute is considered legacy ", + r"The Function.bind argument", + r"The select.bind argument", # # result sets # |
