]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
ensure SQL expressions w/o bool pass through to correct typing error
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 17 Mar 2025 20:46:12 +0000 (16:46 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 17 Mar 2025 22:26:23 +0000 (18:26 -0400)
commitb19a09812c2b0806cc063e42993216fc1ead6ed2
tree7f883b2288b60a3a40914da40de2b1f1c2dba5c3
parent1d49add43530ecb4011b3fcd057a5273a3be774a
ensure SQL expressions w/o bool pass through to correct typing error

Fixed regression which occurred as of 2.0.37 where the checked
:class:`.ArgumentError` that's raised when an inappropriate type or object
is used inside of a :class:`.Mapped` annotation would raise ``TypeError``
with "boolean value of this clause is not defined" if the object resolved
into a SQL expression in a boolean context, for programs where future
annotations mode was not enabled.  This case is now handled explicitly and
a new error message has also been tailored for this case.  In addition, as
there are at least half a dozen distinct error scenarios for intepretation
of the :class:`.Mapped` construct, these scenarios have all been unified
under a new subclass of :class:`.ArgumentError` called
:class:`.MappedAnnotationError`, to provide some continuity between these
different scenarios, even though specific messaging remains distinct.

Fixes: #12329
Change-Id: I0193e3479c84a48b364df8655f050e2e84151122
doc/build/changelog/unreleased_20/12329.rst [new file with mode: 0644]
lib/sqlalchemy/orm/decl_base.py
lib/sqlalchemy/orm/exc.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/orm/util.py
lib/sqlalchemy/util/typing.py
test/orm/declarative/test_tm_future_annotations_sync.py
test/orm/declarative/test_typed_mapping.py