]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
establish column_property and query_expression as readonly from a dc perspective
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 10 Apr 2023 16:56:47 +0000 (12:56 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 12 Apr 2023 19:11:03 +0000 (15:11 -0400)
commit9f43b10e9014e694cb89fe2899dc52f602bf2197
tree03c54cbc80bd98e9d358b6a21a029b8524142696
parent6e5ed192c6435ec107eae524bb2c6959c38bc654
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
16 files changed:
doc/build/changelog/unreleased_20/9628.rst [new file with mode: 0644]
doc/build/orm/declarative_tables.rst
lib/sqlalchemy/ext/mypy/names.py
lib/sqlalchemy/orm/_orm_constructors.py
lib/sqlalchemy/orm/decl_api.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/util/deprecations.py
lib/sqlalchemy/util/langhelpers.py
test/ext/mypy/plain_files/dataclass_transforms_one.py [new file with mode: 0644]
test/ext/mypy/plain_files/pep681.py [deleted file]
test/orm/declarative/test_basic.py
test/orm/declarative/test_dc_transforms.py
test/orm/test_deferred.py
test/orm/test_deprecations.py