]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Mention no_autoflush in warning
authorFederico Caselli <cfederico87@gmail.com>
Thu, 31 Oct 2024 21:14:57 +0000 (22:14 +0100)
committerFederico Caselli <cfederico87@gmail.com>
Thu, 31 Oct 2024 21:16:38 +0000 (22:16 +0100)
References: #12049
Change-Id: I057140b2fe2f5fc60d5d27a79ddf19a6196fff7b
(cherry picked from commit b4fdfd489755848f4945c31f0686ad9eaf128b08)

lib/sqlalchemy/orm/session.py
test/orm/test_utils.py

index eb81f16e01e9efd2911e703c0011ef57f29ea225..f18299b3eafa97cd86c019a689daeca22300a8d6 100644 (file)
@@ -3041,7 +3041,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:
index 4d6c148639f759240b726b9ce473568fec6020b6..35a5060da271671503a61bb95c38f51d5ce64c2b 100644 (file)
@@ -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))