diff options
author | Frederik Aalund <fpa@sbtinstruments.com> | 2023-01-30 11:50:40 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-01-31 22:02:30 -0500 |
commit | 8e890609eb47f5a273e695154cf143af56807921 (patch) | |
tree | 2b687da911107a5c4e86231a1241c5a6ee4dae3f /lib/sqlalchemy/sql/_elements_constructors.py | |
parent | a21c715b7a89b0619db0d2d5b31617d17b25a27a (diff) | |
download | sqlalchemy-8e890609eb47f5a273e695154cf143af56807921.tar.gz |
Add support for typing.Literal in Mapped
Added support for :pep:`586` ``Literal`` to be used in the
:paramref:`_orm.registry.type_annotation_map` as well as within
:class:`.Mapped` constructs. To use custom types such as these, they must
appear explicitly within the :paramref:`_orm.registry.type_annotation_map`
to be mapped. Pull request courtesy Frederik Aalund.
As part of this change, the support for :class:`.sqltypes.Enum` in the
:paramref:`_orm.registry.type_annotation_map` has been expanded to include
support for ``Literal[]`` types consisting of string values to be used,
in addition to ``enum.Enum`` datatypes. If a ``Literal[]`` datatype
is used within ``Mapped[]`` that is not linked in
:paramref:`_orm.registry.type_annotation_map` to a specific datatype,
a :class:`.sqltypes.Enum` will be used by default.
Fixed issue involving the use of :class:`.sqltypes.Enum` within the
:paramref:`_orm.registry.type_annotation_map` where the
:paramref:`_sqltypes.Enum.native_enum` parameter would not be correctly
copied to the mapped column datatype, if it were overridden
as stated in the documentation to set this parameter to False.
Fixes: #9187
Fixes: #9200
Closes: #9191
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9191
Pull-request-sha: 7d13f705307bf62560fc831f6f049a425d411374
Change-Id: Ife3ba2655f4897f806d6a9cf0041c69fd4f39e9d
Diffstat (limited to 'lib/sqlalchemy/sql/_elements_constructors.py')
0 files changed, 0 insertions, 0 deletions