]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
allow batch with upsert if embed_values_counter is True
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 4 Feb 2026 02:07:59 +0000 (21:07 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 5 Feb 2026 15:09:09 +0000 (10:09 -0500)
commit574facaaf4207b952379c28673c44b62835535fb
tree42e76bf58b20a549a6a3f1705438f7ef230e7530
parente0f13cb6c1c3f44ebd110e8e32147d9f853146d4
allow batch with upsert if embed_values_counter is True

Fixed issue in the :ref:`engine_insertmanyvalues` feature where using
PostgreSQL's ``ON CONFLICT`` clause with
:paramref:`_dml.Insert.returning.sort_by_parameter_order` enabled would
generate invalid SQL when the insert used an implicit sentinel (server-side
autoincrement primary key). The generated SQL would incorrectly declare a
sentinel counter column in the ``imp_sen`` table alias without providing
corresponding values in the ``VALUES`` clause, leading to a
``ProgrammingError`` indicating column count mismatch. The fix allows batch
execution mode when ``embed_values_counter`` is active, as the embedded
counter provides the ordering capability needed even with upsert behaviors,
rather than unnecessarily downgrading to row-at-a-time execution.

Fixes: #13107
Change-Id: I382472b2cf2991b520344adea5783584e27425d0
doc/build/changelog/unreleased_20/13107.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/provision.py
lib/sqlalchemy/dialects/postgresql/provision.py
lib/sqlalchemy/dialects/sqlite/provision.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/testing/provision.py
test/dialect/postgresql/test_on_conflict.py
test/sql/test_insert_exec.py