]> 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:30:45 +0000 (18:30 -0500)
commit40c30ec44616223216737327f97bac66a13eedee
tree9f59a504dd4a3aa6bf653f91eb6d380add99edca
parent5ded16fae8abfc31d43430cb25757fb434c37ba2
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
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