]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Unconditionally flush session on all statement executions
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Jul 2025 19:29:29 +0000 (15:29 -0400)
committerMichael Bayer <mike_mp@zzzcomputing.com>
Sun, 13 Jul 2025 21:45:26 +0000 (21:45 +0000)
commit45a5c31e5c49e9b6e288465bcce30b87136871c0
treef16097b8a22d3aa0acc26fc8bee398170a1c213d
parent2ac0c459669d0200a4d15162ffc0a8765c60cb07
Unconditionally flush session on all statement executions

This change simplifies session execution logic to always run autoflush
for all statement executions, regardless of whether they are ORM or Core
statements. Previously, autoflush was conditionally applied only when
ORM-related statements were detected, which had become difficult to define
clearly with the unified v2 syntax that blurs the lines between Core and
ORM execution patterns.

The implementation adds a call to self._autoflush() in the Core execution
path (when compile_state_cls is None) in Session._execute_internal(),
ensuring consistent autoflush behavior across all types of SQL execution.

This provides more predictable session behavior and eliminates the
confusion around which statements trigger autoflush.

Also included is some improvement to the migration_21 document

Fixes: #9809
Change-Id: I0b1974f1981c8a747a0feaaca74ed45106b2b160
doc/build/changelog/migration_21.rst
doc/build/changelog/unreleased_21/9809.rst [new file with mode: 0644]
doc/build/index.rst
lib/sqlalchemy/orm/session.py
test/orm/test_core_compilation.py