]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
dont match partial types in type_annotation_map
authorFrazer McLean <frazer@frazermclean.co.uk>
Thu, 3 Oct 2024 22:21:12 +0000 (18:21 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 10 Dec 2024 23:33:53 +0000 (18:33 -0500)
commit8a45f13ef66628c5d5ff30bed30c3a62874f041e
treef503cde46f499f30271cef093d63230e7c0561eb
parente4771b81ca5f84df1ad11d6e1289a76b0d88283e
dont match partial types in type_annotation_map

Fixed issue regarding ``Union`` types that would be present in the
:paramref:`_orm.registry.type_annotation_map` of a :class:`_orm.registry`
or declarative base class, where a ``Mapped[]`` element that included one
of the subtypes present in that ``Union`` would be matched to that entry,
potentially ignoring other entries that matched exactly.   The correct
behavior now takes place such that an entry should only match in
``type_annotation_map`` exactly, as a ``Union`` type is a self-contained
type. For example, an attribute with ``Mapped[float]`` would previously
match to a ``type_annotation_map`` entry ``Union[float, Decimal]``; this
will no longer match and will now only match to an entry that states
``float``. Pull request courtesy Frazer McLean.

Fixes #11370
Closes: #11942
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11942
Pull-request-sha: 21a3d1971a04e117a557f6e6bac77bce9f6bb0a9

Change-Id: I3467be00f8fa8bd011dd4805a77a3b80ff74a215
(cherry picked from commit 40c30ec44616223216737327f97bac66a13eedee)
doc/build/changelog/unreleased_20/11370.rst [new file with mode: 0644]
lib/sqlalchemy/orm/decl_api.py
lib/sqlalchemy/util/typing.py
test/base/test_utils.py
test/orm/declarative/test_tm_future_annotations_sync.py
test/orm/declarative/test_typed_mapping.py