]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add support for 'code' in deprecation warnings
authorStephen Rosen <sirosen@globus.org>
Mon, 12 Apr 2021 17:57:17 +0000 (17:57 +0000)
committerStephen Rosen <sirosen@globus.org>
Fri, 7 May 2021 15:59:59 +0000 (15:59 +0000)
commit824a7890a09f495e05ea5acd8f37b7dc4f1e404d
treebcda9f391df600d37acda2f69259f6d7c120bf9a
parente50e0de842a489bb4b064729cbccfdea3f833731
Add support for 'code' in deprecation warnings

SADeprecationWarning and SQLAlchemyError now share 'code' and
'_code_str' through a small mixin/helper class.

In the case of the deprecation warnings, the code_str is injected into
`__str__`, which means the message will be built when a warning is
emitted. An alternative approach would be to build a distinct message
when the warning is instantiated.

`s9r1` is a new error code which points directly to the documentation
on backref cascades, and this is now in place as the code for
`cascade_backrefs` warnings.

Fixes: #6148
doc/build/orm/cascades.rst
lib/sqlalchemy/exc.py
lib/sqlalchemy/orm/unitofwork.py
lib/sqlalchemy/util/deprecations.py