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/util | |
| 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/util')
| -rw-r--r-- | lib/sqlalchemy/util/deprecations.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util/deprecations.py b/lib/sqlalchemy/util/deprecations.py index 097150712..e32ab9e0d 100644 --- a/lib/sqlalchemy/util/deprecations.py +++ b/lib/sqlalchemy/util/deprecations.py @@ -226,6 +226,7 @@ def deprecated_params(**specs: Tuple[str, str]) -> Callable[[_F], _F]: check_defaults: Union[Set[str], Tuple[()]] if spec.defaults is not None: + defaults = dict( zip( spec.args[(len(spec.args) - len(spec.defaults)) :], @@ -234,6 +235,11 @@ def deprecated_params(**specs: Tuple[str, str]) -> Callable[[_F], _F]: ) check_defaults = set(defaults).intersection(messages) check_kw = set(messages).difference(defaults) + elif spec.kwonlydefaults is not None: + + defaults = spec.kwonlydefaults + check_defaults = set(defaults).intersection(messages) + check_kw = set(messages).difference(defaults) else: check_defaults = () check_kw = set(messages) diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 6ff069c4e..903d8bdeb 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -290,6 +290,9 @@ def %(name)s%(grouped_args)s: """ % metadata ) + + mod = sys.modules[fn.__module__] + env.update(vars(mod)) env.update({targ_name: target, fn_name: fn, "__name__": fn.__module__}) decorated = cast( |
