From: Federico Caselli Date: Thu, 31 Oct 2024 21:14:57 +0000 (+0100) Subject: Mention no_autoflush in warning X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4fdfd489755848f4945c31f0686ad9eaf128b08;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Mention no_autoflush in warning References: #12049 Change-Id: I057140b2fe2f5fc60d5d27a79ddf19a6196fff7b --- diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index a23239e098..c27ca10320 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -3055,7 +3055,8 @@ class Session(_SessionClassMethods, EventTarget): @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.", + "operation. Consider using ``no_autoflush`` context manager if this " + "warning happended while initializing objects.", sa_exc.SAWarning, ) def _autoflush(self) -> None: diff --git a/test/orm/test_utils.py b/test/orm/test_utils.py index 4d6c148639..35a5060da2 100644 --- a/test/orm/test_utils.py +++ b/test/orm/test_utils.py @@ -140,7 +140,9 @@ class ContextualWarningsTest(fixtures.TestBase): + re.escape( "(This warning originated from the Session 'autoflush' " "process, which was invoked automatically in response to a " - "user-initiated operation.)" + "user-initiated operation. Consider using ``no_autoflush`` " + "context manager if this warning happended while " + "initializing objects.)" ), ): sess.execute(select(Foo))