summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/session.py
diff options
context:
space:
mode:
authorjonathan vanasco <jonathan@2xlp.com>2021-11-12 12:45:54 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2023-01-24 22:03:06 -0500
commit03212e5aefb3d5c912d25274f447eb9c493f7268 (patch)
treefdf6b7919dab70e979304f43b6fbde9b8ad6515b /lib/sqlalchemy/orm/session.py
parent55b243a3f22f267c829f9088fd4e801f0b621a31 (diff)
downloadsqlalchemy-03212e5aefb3d5c912d25274f447eb9c493f7268.tar.gz
add context for warnings emitted from configure_mappers(), autoflush()
Improved the notification of warnings that are emitted within the configure mappers or flush process, which are often invoked as part of a different operation, to add additional context to the message that indicates one of these operations as the source of the warning within operations that may not be obviously related. Fixes: #7305 Change-Id: I79da7a6a5d4cf67d57615d0ffc2b8d8454011c84
Diffstat (limited to 'lib/sqlalchemy/orm/session.py')
-rw-r--r--lib/sqlalchemy/orm/session.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index 5bcb22a08..06e84dbcf 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -2872,6 +2872,12 @@ class Session(_SessionClassMethods, EventTarget):
finally:
self.autoflush = autoflush
+ @util.langhelpers.tag_method_for_warnings(
+ "This warning originated from the Session 'autoflush' process, "
+ "which was invoked automatically in response to a user-initiated "
+ "operation.",
+ sa_exc.SAWarning,
+ )
def _autoflush(self) -> None:
if self.autoflush and not self._flushing:
try: