summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-10-17 14:11:48 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-10-17 14:11:48 +0000
commit3179f70408cb91c7586fc2021959efb5b2fe9f0e (patch)
tree7a06d860fd90800b2536eef3dbbd702c4f25c044 /lib/sqlalchemy
parent87c24c498cb660e7a8d7d4dd5f630b967f79d3c8 (diff)
parent5162f2bc5fc0ac239f26a76fc9f0c2c2472adf60 (diff)
downloadsqlalchemy-3179f70408cb91c7586fc2021959efb5b2fe9f0e.tar.gz
Merge "Add deprecation for base Executable.bind"
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/sql/base.py4
-rw-r--r--lib/sqlalchemy/sql/selectable.py23
-rw-r--r--lib/sqlalchemy/testing/warnings.py21
-rw-r--r--lib/sqlalchemy/util/deprecations.py12
4 files changed, 48 insertions, 12 deletions
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
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py
index 8ccb6516a..f3eb2b135 100644
--- a/lib/sqlalchemy/testing/warnings.py
+++ b/lib/sqlalchemy/testing/warnings.py
@@ -50,13 +50,13 @@ def setup_filters():
#
# Core execution
#
- r"The (?:Executable|Engine)\.(?:execute|scalar)\(\) function",
+ r"The (?:Executable|Engine)\.(?:execute|scalar)\(\) method",
r"The current statement is being autocommitted using implicit "
"autocommit,",
r"The connection.execute\(\) method in SQLAlchemy 2.0 will accept "
"parameters as a single dictionary or a single sequence of "
"dictionaries only.",
- r"The Connection.connect\(\) function/method is considered legacy",
+ r"The Connection.connect\(\) method is considered legacy",
r".*DefaultGenerator.execute\(\)",
r"The autoload parameter is deprecated and will be removed ",
#
@@ -65,10 +65,11 @@ 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 ",
#
# result sets
#
- r"The Row.keys\(\) function/method",
+ r"The Row.keys\(\) method",
r"Using non-integer/slice indices on Row ",
#
# Core SQL constructs
@@ -106,18 +107,18 @@ def setup_filters():
#
# ORM Query
#
- r"The Query\.get\(\) function",
- r"The Query\.from_self\(\) function",
- r"The Query\.with_parent\(\) function",
- r"The Query\.with_parent\(\) function",
- r"The Query\.select_entity_from\(\) function",
+ r"The Query\.get\(\) method",
+ r"The Query\.from_self\(\) method",
+ r"The Query\.with_parent\(\) method",
+ r"The Query\.with_parent\(\) method",
+ r"The Query\.select_entity_from\(\) method",
r"The ``aliased`` and ``from_joinpoint`` keyword arguments",
r"Using strings to indicate relationship names in Query.join",
r"Using strings to indicate column or relationship paths in "
"loader options",
r"Using strings to indicate relationship names in the ORM "
r"with_parent\(\)",
- r"The Query.with_polymorphic\(\) function/method is considered "
+ r"The Query.with_polymorphic\(\) method is considered "
"legacy as of the 1.x series",
r"Passing a chain of multiple join conditions to Query.join\(\) "
r"is deprecated and will be removed in SQLAlchemy 2.0.",
@@ -130,7 +131,7 @@ def setup_filters():
r".*object is being merged into a Session along the backref "
"cascade path",
r"Passing bind arguments to Session.execute\(\) as keyword arguments",
- r"The Session.transaction function/method",
+ r"The Session.transaction attribute",
r"The merge_result\(\) method is superseded by the "
r"merge_frozen_result\(\)",
r"The Session.begin.subtransactions flag is deprecated",
diff --git a/lib/sqlalchemy/util/deprecations.py b/lib/sqlalchemy/util/deprecations.py
index 83037bbff..9f0ca0b1a 100644
--- a/lib/sqlalchemy/util/deprecations.py
+++ b/lib/sqlalchemy/util/deprecations.py
@@ -162,9 +162,17 @@ def moved_20(message, **kw):
def deprecated_20(api_name, alternative=None, **kw):
+ type_reg = re.match("^:(attr|func|meth):", api_name)
+ if type_reg:
+ type_ = {"attr": "attribute", "func": "function", "meth": "method"}[
+ type_reg.group(1)
+ ]
+ else:
+ type_ = "construct"
message = (
- "The %s function/method is considered legacy as of the "
- "1.x series of SQLAlchemy and will be removed in 2.0." % api_name
+ "The %s %s is considered legacy as of the "
+ "1.x series of SQLAlchemy and will be removed in 2.0."
+ % (api_name, type_)
)
if alternative: