summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util/langhelpers.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-03-31 13:16:04 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-03-31 13:23:53 -0400
commitb99f8cad8d290bfa123742eafa9d381cb7644cd1 (patch)
tree5c5d4f9d4ebaba8e8d1fad7fe4c1d9f34a206693 /lib/sqlalchemy/util/langhelpers.py
parent42185a1f3866bfc8ebffa2a6c724face8a2db5dc (diff)
downloadsqlalchemy-b99f8cad8d290bfa123742eafa9d381cb7644cd1.tar.gz
Expand sibling tests for overlaps warning
Scaled back the warning message added in :ticket:`5171` to not warn for overlapping columns in an inheritance scenario where a particular relationship is local to a subclass and therefore does not represent an overlap. Add errors documentation for the warning and also expand ``util.warn()`` to include a code parameter. Fixes: #6171 Change-Id: Icb1f12d8d645d439ffd2bbb7371c6b00042b6ae3
Diffstat (limited to 'lib/sqlalchemy/util/langhelpers.py')
-rw-r--r--lib/sqlalchemy/util/langhelpers.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py
index 51b9071d5..b31f316fe 100644
--- a/lib/sqlalchemy/util/langhelpers.py
+++ b/lib/sqlalchemy/util/langhelpers.py
@@ -1604,13 +1604,16 @@ class _hash_limit_string(compat.text_type):
return hash(self) == hash(other)
-def warn(msg):
+def warn(msg, code=None):
"""Issue a warning.
If msg is a string, :class:`.exc.SAWarning` is used as
the category.
"""
+ if code:
+ msg = "%s %s" % (msg, exc.SQLAlchemyError(msg, code=code)._code_str())
+
warnings.warn(msg, exc.SAWarning, stacklevel=2)