]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
dont enter do_executemany if implicit_returning is False
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 11 Oct 2023 14:28:34 +0000 (10:28 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 11 Oct 2023 22:27:27 +0000 (18:27 -0400)
commit20c1b1b1ede5d66e38ca1c4ae4a708fc33245b1d
treeb9fdcb8939459d0e80f5b3779c53af0e11c85976
parenta342b3d503f968bbf43f3b2de1f4f623b03a6310
dont enter do_executemany if implicit_returning is False

Fixed regression in recently revised "insertmanyvalues" feature (likely
issue :ticket:`9618`) where the ORM would inadvertently attempt to
interpret a non-RETURNING result as one with RETURNING, in the case where
the ``implicit_returning=False`` parameter were applied to the mapped
:class:`.Table`, indicating that "insertmanyvalues" cannot be used if the
primary key values are not provided.

This includes a refinement to insertmanyvalues where we consider
return_defaults() with supplemental_cols to be the same as an explicit
returning(), since that's the purpose of this.  This saves us some
extra exceptions that could be thrown per-dialect if implicit_returning
were set to False in some cases.

Fixed issue within some dialects where the dialect could incorrectly return
an empty result set for an INSERT statement that does not actually return
rows at all, due to artfacts from pre- or post-fetching the primary key of
the row or rows still being present.  Affected dialects included asyncpg,
all mssql dialects.

Fixes: #10453
Change-Id: Ie2e7e4f4cd9180558f9da315d21895347ec6d4f7
12 files changed:
doc/build/changelog/unreleased_20/10453.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/dialects/mssql/pyodbc.py
lib/sqlalchemy/dialects/postgresql/asyncpg.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/orm/persistence.py
lib/sqlalchemy/sql/crud.py
lib/sqlalchemy/sql/dml.py
lib/sqlalchemy/testing/suite/test_insert.py
test/orm/dml/test_bulk_statements.py
test/orm/test_unitofworkv2.py
test/sql/test_returning.py