]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add type awareness to evaluator
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 13 Sep 2022 15:00:46 +0000 (11:00 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 15 Sep 2022 12:54:58 +0000 (08:54 -0400)
commit7c63437219aa361c50ef2de4b0e34bc670e87243
treec4fb4163e9db6eb90e48f9d76d1b50bb5b0aa10b
parent3b8bcbcac66d814d15ec44c86c30d9c48ec40c27
Add type awareness to evaluator

Fixed regression where using ORM update() with synchronize_session='fetch'
would fail due to the use of evaluators that are now used to determine the
in-Python value for expressions in the the SET clause when refreshing
objects; if the evaluators make use of math operators against non-numeric
values such as PostgreSQL JSONB, the non-evaluable condition would fail to
be detected correctly. The evaluator now limits the use of math mutation
operators to numeric types only, with the exception of "+" that continues
to work for strings as well. SQLAlchemy 2.0 may alter this further by
fetching the SET values completely rather than using evaluation.

For 1.4 this also adds "concat_op" as evaluable; 2.0 already has
more string operator support

Fixes: #8507
Change-Id: Icf7120ccbf4266499df6bb3e05159c9f50971d69
(cherry picked from commit 4ab1bc641c7d5833cf20d8ab9b38f5bfba37cfdd)
doc/build/changelog/unreleased_14/8507.rst [new file with mode: 0644]
lib/sqlalchemy/orm/evaluator.py
test/orm/test_evaluator.py