summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-10-26 15:37:16 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-10-27 11:41:00 -0400
commit0f98ead274df103a5a623baa3898580932e1c8e2 (patch)
treef2c9acf56b9144e7ce3817a6066fedbe481ef540 /lib/sqlalchemy
parentd2cf7dcfe0cd7e9986376b6e7edd4b7d60108599 (diff)
downloadsqlalchemy-0f98ead274df103a5a623baa3898580932e1c8e2.tar.gz
deprecation warnings: with_parent, aliased, from_joinpoint
most of the work for aliased / from_joinpoint has been done already as I added all new tests for these and moved most aliased/from_joinpoint to test/orm/test_deprecations.py already Change-Id: Ia23e332dec183de17b2fb9d89d946af8d5e89ae7
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/exc.py15
-rw-r--r--lib/sqlalchemy/orm/query.py1
-rw-r--r--lib/sqlalchemy/testing/assertions.py2
-rw-r--r--lib/sqlalchemy/testing/warnings.py3
-rw-r--r--lib/sqlalchemy/util/deprecations.py9
5 files changed, 21 insertions, 9 deletions
diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py
index 9b9c82aca..7fa77120c 100644
--- a/lib/sqlalchemy/exc.py
+++ b/lib/sqlalchemy/exc.py
@@ -685,8 +685,9 @@ class SADeprecationWarning(HasDescriptionCode, DeprecationWarning):
"Indicates the version that started raising this deprecation warning"
-class RemovedIn20Warning(SADeprecationWarning):
- """Issued for usage of APIs specifically deprecated in SQLAlchemy 2.0.
+class Base20DeprecationWarning(SADeprecationWarning):
+ """Issued for usage of APIs specifically deprecated or legacy in
+ SQLAlchemy 2.0.
.. seealso::
@@ -701,11 +702,19 @@ class RemovedIn20Warning(SADeprecationWarning):
def __str__(self):
return (
- super(RemovedIn20Warning, self).__str__()
+ super(Base20DeprecationWarning, self).__str__()
+ " (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)"
)
+class LegacyAPIWarning(Base20DeprecationWarning):
+ """indicates an API that is in 'legacy' status, a long term deprecation."""
+
+
+class RemovedIn20Warning(Base20DeprecationWarning):
+ """indicates an API that will be fully removed in SQLAlchemy 2.0."""
+
+
class MovedIn20Warning(RemovedIn20Warning):
"""Subtype of RemovedIn20Warning to indicate an API that moved only."""
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index d48e34923..eddb9c29c 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -1711,6 +1711,7 @@ class Query(
we will attempt to derive an expression from based on string name.
"""
+
if self._legacy_setup_joins:
_last_joined_entity = self._last_joined_entity
if _last_joined_entity is not None:
diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py
index 986dbb5e9..6bf14aecd 100644
--- a/lib/sqlalchemy/testing/assertions.py
+++ b/lib/sqlalchemy/testing/assertions.py
@@ -86,7 +86,7 @@ def expect_deprecated(*messages, **kw):
def expect_deprecated_20(*messages, **kw):
- return _expect_warnings(sa_exc.RemovedIn20Warning, messages, **kw)
+ return _expect_warnings(sa_exc.Base20DeprecationWarning, messages, **kw)
def emits_warning_on(db, *messages):
diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py
index 40d03f0af..f29d65692 100644
--- a/lib/sqlalchemy/testing/warnings.py
+++ b/lib/sqlalchemy/testing/warnings.py
@@ -69,9 +69,6 @@ def setup_filters():
# ORM Query
#
r"The Query\.get\(\) method",
- r"The Query\.with_parent\(\) method",
- r"The Query\.with_parent\(\) method",
- r"The ``aliased`` and ``from_joinpoint`` keyword arguments",
r"The Query.with_polymorphic\(\) method is considered "
"legacy as of the 1.x series",
#
diff --git a/lib/sqlalchemy/util/deprecations.py b/lib/sqlalchemy/util/deprecations.py
index c1acde39b..e1138aaef 100644
--- a/lib/sqlalchemy/util/deprecations.py
+++ b/lib/sqlalchemy/util/deprecations.py
@@ -98,13 +98,18 @@ def deprecated_20_cls(
if alternative:
message += " " + alternative
+ if becomes_legacy:
+ warning_cls = exc.LegacyAPIWarning
+ else:
+ warning_cls = exc.RemovedIn20Warning
+
def decorate(cls):
return _decorate_cls_with_warning(
cls,
constructor,
- exc.RemovedIn20Warning,
+ warning_cls,
message,
- exc.RemovedIn20Warning.deprecated_since,
+ warning_cls.deprecated_since,
message,
)