From 5162f2bc5fc0ac239f26a76fc9f0c2c2472adf60 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 16 Oct 2020 12:03:11 -0400 Subject: Add deprecation for base Executable.bind These attributes will be removed in SQLAlchemy 2.0. Also alters the deprecation message to qualify the type of object correctly. this in turn requires changes in the warnings filter and deprecation tests. Change-Id: I5779d9813e88f42e5db0c7b5e3ffff1d1535c203 --- lib/sqlalchemy/sql/base.py | 4 ++++ lib/sqlalchemy/sql/selectable.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index ba1107eac..4175fe89a 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -904,6 +904,10 @@ class Executable(Generative): return self.execute(*multiparams, **params).scalar() @property + @util.deprecated_20( + ":attr:`.Executable.bind`", + alternative="Bound metadata is being removed as of SQLAlchemy 2.0.", + ) def bind(self): """Returns the :class:`_engine.Engine` or :class:`_engine.Connection` to diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index eebf3b96e..0e88a8999 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -1221,7 +1221,14 @@ class Join(roles.DMLTableRole, FromClause): ).select_from(self) @property + @util.deprecated_20( + ":attr:`.Executable.bind`", + alternative="Bound metadata is being removed as of SQLAlchemy 2.0.", + ) def bind(self): + """Return the bound engine associated with either the left or right + side of this :class:`_sql.Join`.""" + return self.left.bind or self.right.bind @util.preload_module("sqlalchemy.sql.util") @@ -3487,7 +3494,15 @@ class CompoundSelect(HasCompileState, GenerativeSelect): return self.selects[0].selected_columns @property + @util.deprecated_20( + ":attr:`.Executable.bind`", + alternative="Bound metadata is being removed as of SQLAlchemy 2.0.", + ) def bind(self): + """Returns the :class:`_engine.Engine` or :class:`_engine.Connection` + to which this :class:`.Executable` is bound, or None if none found. + + """ if self._bind: return self._bind for s in self.selects: @@ -5348,7 +5363,15 @@ class Select( return CompoundSelect._create_intersect_all(self, other, **kwargs) @property + @util.deprecated_20( + ":attr:`.Executable.bind`", + alternative="Bound metadata is being removed as of SQLAlchemy 2.0.", + ) def bind(self): + """Returns the :class:`_engine.Engine` or :class:`_engine.Connection` + to which this :class:`.Executable` is bound, or None if none found. + + """ if self._bind: return self._bind -- cgit v1.2.1