]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
run sentinel server side fns outside of VALUES
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 1 Dec 2025 20:11:50 +0000 (15:11 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Dec 2025 03:52:57 +0000 (22:52 -0500)
commitc5d09f5ed4b4e37cfdd033026e2f67382ee9fcb3
treea38db564d2db53af10550085d7832e6c775569b7
parentb9e3cacb0e7025a31458f09d0cb0c72da0c5f660
run sentinel server side fns outside of VALUES

Fixed the structure of the SQL string used for the
:ref:`engine_insertmanyvalues` feature when an explicit sequence with
``nextval()`` is used. The SQL function invocation for the sequence has
been moved from being rendered inline within each tuple inside of VALUES to
being rendered once in the SELECT that reads from VALUES. This change
ensures the function is invoked in the correct order as rows are processed,
rather than assuming PostgreSQL will execute inline function calls within
VALUES in a particular order. While current PostgreSQL versions appear to
handle the previous approach correctly, the database does not guarantee
this behavior for future versions.

Fixes: #13015
Change-Id: Ia0a2a4e8f89e21852d7cb550dfa5d9ea9447b590
doc/build/changelog/unreleased_20/13015.rst [new file with mode: 0644]
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/crud.py
lib/sqlalchemy/testing/assertsql.py
test/dialect/postgresql/test_query.py