]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
remove sentinel_value_resolvers and use pre-bind values
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 15 Mar 2024 14:51:02 +0000 (10:51 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 18 Mar 2024 14:20:51 +0000 (10:20 -0400)
commit7609fb5d8bac8574d7329ecad9925b9139750a2d
tree9e2a4218d8d1a76e5f26d5ab2b6967515473b76e
parentf9b77670126c3639cd878f62e64b3fad62a35253
remove sentinel_value_resolvers and use pre-bind values

Made a change to the adjustment made in version 2.0.10 for :ticket:`9618`,
which added the behavior of reconciling RETURNING rows from a bulk INSERT
to the parameters that were passed to it.  This behavior included a
comparison of already-DB-converted bound parameter values against returned
row values that was not always "symmetrical" for SQL column types such as
UUIDs, depending on specifics of how different DBAPIs receive such values
versus how they return them, necessitating the need for additional
"sentinel value resolver" methods on these column types.  Unfortunately
this broke third party column types such as UUID/GUID types in libraries
like SQLModel which did not implement this special method, raising an error
"Can't match sentinel values in result set to parameter sets".  Rather than
attempt to further explain and document this implementation detail of the
"insertmanyvalues" feature including a public version of the new
method, the approach is intead revised to no longer need this extra
conversion step, and the logic that does the comparison now works on the
pre-converted bound parameter value compared to the post-result-processed
value, which should always be of a matching datatype.  In the unusual case
that a custom SQL column type that also happens to be used in a "sentinel"
column for bulk INSERT is not receiving and returning the same value type,
the "Can't match" error will be raised, however the mitigation is
straightforward in that the same Python datatype should be passed as that
returned.

Fixes: #11160
Change-Id: Ica62571e923ad9545eb90502e6732b11875b164a
(cherry picked from commit 4c0af9e93dab62a04aa00f7c9a07c984e0e316df)
doc/build/changelog/unreleased_20/11160.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/sqltypes.py
lib/sqlalchemy/sql/type_api.py
lib/sqlalchemy/testing/fixtures/sql.py
setup.cfg
test/sql/test_insert_exec.py