]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
support NewType in type_annotation_map
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 30 Jan 2023 20:12:52 +0000 (15:12 -0500)
committermike bayer <mike_mp@zzzcomputing.com>
Tue, 31 Jan 2023 19:13:16 +0000 (19:13 +0000)
commita21c715b7a89b0619db0d2d5b31617d17b25a27a
tree01971eece9c687570137dd6e5d8e86b6040b697c
parent6d6a17240815b9090a2972607657f93d347167d6
support NewType in type_annotation_map

Added support for :pep:`484` ``NewType`` to be used in the
:paramref:`_orm.registry.type_annotation_map` as well as within
:class:`.Mapped` constructs. These types will behave in the same way as
custom subclasses of types right now; they must appear explicitly within
the :paramref:`_orm.registry.type_annotation_map` to be mapped.

Within this change, the lookup between decl_api._resolve_type
and TypeEngine._resolve_for_python_type is streamlined to not
inspect the given type multiple times, instead passing
in from decl_api to TypeEngine the already "flattened" version
of a Generic or NewType type.

Fixes: #9175
Change-Id: I227cf84b4b88e4567fa2d1d7da0c05b54e00c562
doc/build/changelog/unreleased_20/9175.rst [new file with mode: 0644]
lib/sqlalchemy/orm/decl_api.py
lib/sqlalchemy/sql/sqltypes.py
lib/sqlalchemy/sql/type_api.py
lib/sqlalchemy/util/typing.py
test/orm/declarative/test_tm_future_annotations_sync.py
test/orm/declarative/test_typed_mapping.py