diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-04-10 12:56:47 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-04-12 15:11:03 -0400 |
commit | 9f43b10e9014e694cb89fe2899dc52f602bf2197 (patch) | |
tree | 03c54cbc80bd98e9d358b6a21a029b8524142696 /lib/sqlalchemy/sql/base.py | |
parent | 6e5ed192c6435ec107eae524bb2c6959c38bc654 (diff) | |
download | sqlalchemy-9f43b10e9014e694cb89fe2899dc52f602bf2197.tar.gz |
establish column_property and query_expression as readonly from a dc perspective
Fixed bug in ORM Declarative Dataclasses where the
:func:`_orm.queryable_attribute` and :func:`_orm.column_property`
constructs, which are documented as read-only constructs in the context of
a Declarative mapping, could not be used with a
:class:`_orm.MappedAsDataclass` class without adding ``init=False``, which
in the case of :func:`_orm.queryable_attribute` was not possible as no
``init`` parameter was included. These constructs have been modified from a
dataclass perspective to be assumed to be "read only", setting
``init=False`` by default and no longer including them in the pep-681
constructor. The dataclass parameters for :func:`_orm.column_property`
``init``, ``default``, ``default_factory``, ``kw_only`` are now deprecated;
these fields don't apply to :func:`_orm.column_property` as used in a
Declarative dataclasses configuration where the construct would be
read-only. Also added read-specific parameter
:paramref:`_orm.queryable_attribute.compare` to
:func:`_orm.queryable_attribute`; :paramref:`_orm.queryable_attribute.repr`
was already present.
Added missing :paramref:`_orm.mapped_column.active_history` parameter
to :func:`_orm.mapped_column` construct.
Fixes: #9628
Change-Id: I2ab44d6b763b20410bd1ebb5ac949a6d223f1ce2
Diffstat (limited to 'lib/sqlalchemy/sql/base.py')
-rw-r--r-- | lib/sqlalchemy/sql/base.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 1752a4dc1..8186f6ade 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -101,6 +101,9 @@ if not TYPE_CHECKING: class _NoArg(Enum): NO_ARG = 0 + def __repr__(self): + return f"_NoArg.{self.name}" + NO_ARG = _NoArg.NO_ARG |