diff options
Diffstat (limited to 'lib/sqlalchemy/util/langhelpers.py')
-rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 5 |
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) |