summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2023-01-30 13:28:42 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2023-01-30 15:40:20 -0500
commit4d3a50c2f1af894b081c5f64c529da89f35f1839 (patch)
tree19e5e5f294c7dd627806c6aeb50d814402dcd4a0 /lib/sqlalchemy/sql/selectable.py
parentbcb5c850f2a5279bf7a97af6fbf99cc63dffd62f (diff)
downloadsqlalchemy-4d3a50c2f1af894b081c5f64c529da89f35f1839.tar.gz
MappedAsDataclass applies @dataclasses.dataclass unconditionally
When using the :class:`.MappedAsDataclass` superclass, all classes within the hierarchy that are subclasses of this class will now be run through the ``@dataclasses.dataclass`` function whether or not they are actually mapped, so that non-ORM fields declared on non-mapped classes within the hierarchy will be used when mapped subclasses are turned into dataclasses. This behavior applies both to intermediary classes mapped with ``__abstract__ = True`` as well as to the user-defined declarative base itself, assuming :class:`.MappedAsDataclass` is present as a superclass for these classes. This allows non-mapped attributes such as ``InitVar`` declarations on superclasses to be used, without the need to run the ``@dataclasses.dataclass`` decorator explicitly on each non-mapped class. The new behavior is considered as correct as this is what the :pep:`681` implementation expects when using a superclass to indicate dataclass behavior. Fixes: #9179 Change-Id: Ia01fa9806a27f7c1121bf7eaddf2847cf6dc5313
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
0 files changed, 0 insertions, 0 deletions