]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Support dataclass default with init=False
authorFederico Caselli <cfederico87@gmail.com>
Sat, 3 Jun 2023 10:40:00 +0000 (12:40 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Sat, 3 Jun 2023 10:40:00 +0000 (12:40 +0200)
commit8f720e1529af2b4810b0ae5379e13b343155eded
treed4430a45d9789d1709f37b0ebf081487da356d4a
parent14825668ab407115f793dd229ed694c5c607c657
Support dataclass default with init=False

Fixed an issue where generating dataclasses fields that specified a
default`` value and set ``init=False`` would not work.
The dataclasses behavior in this case is to set the default
value on the class, that's not compatible with the descriptors used
by SQLAlchemy. To support this case the default is transformed to
a ``default_factory`` when generating the dataclass.

Fixes: #9879
Change-Id: I5151d388232eacd506a100ba18ce26970bf83cf3
doc/build/changelog/unreleased_20/9879.rst [new file with mode: 0644]
lib/sqlalchemy/orm/interfaces.py
test/orm/declarative/test_dc_transforms.py