From 933a3eca9600d3654f459274aa35df7aec77c83d Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Thu, 30 Nov 2023 22:40:43 +0100 Subject: [PATCH] Improve session after_begin even documentation Change-Id: Ie2a1e6bdf5960208921dc76e372fe51d3b280f1a References: #10687 (cherry picked from commit 842b3ebb4b9e40ce3f6aa4257bd5e585c42e51d2) --- lib/sqlalchemy/orm/events.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py index e7e3e32a7f..1a54dfd49a 100644 --- a/lib/sqlalchemy/orm/events.py +++ b/lib/sqlalchemy/orm/events.py @@ -2035,7 +2035,14 @@ class SessionEvents(event.Events[Session]): transaction: SessionTransaction, connection: Connection, ) -> None: - """Execute after a transaction is begun on a connection + """Execute after a transaction is begun on a connection. + + .. note:: This event is called within the process of the + :class:`_orm.Session` modifying its own internal state. + To invoke SQL operations within this hook, use the + :class:`_engine.Connection` provided to the event; + do not run SQL operations using the :class:`_orm.Session` + directly. :param session: The target :class:`.Session`. :param transaction: The :class:`.SessionTransaction`. -- 2.47.2