Skip to content

AI junk - #1430

Closed
DSeaStar wants to merge 1 commit into
pallets-eco:mainfrom
DSeaStar:fix-mapped-as-dataclass-sqlalchemy-21
Closed

AI junk#1430
DSeaStar wants to merge 1 commit into
pallets-eco:mainfrom
DSeaStar:fix-mapped-as-dataclass-sqlalchemy-21

Conversation

@DSeaStar

Copy link
Copy Markdown

When wrapping a SQLAlchemy 2.x model_class, _make_declarative_base copied the user class __dict__ into the new FlaskSQLAlchemyBase. If that class already mixed in MappedAsDataclass, the copy included __dataclass_fields__. SQLAlchemy 2.1 treats that as mixing decorator and base-class dataclass styles and raises InvalidRequestError.

Skip those dataclass bookkeeping keys so MappedAsDataclass can apply to the wrapped base. Existing MappedAsDataclass construction tests cover this; verified on SQLAlchemy 2.0.52 and 2.1.0b1.

fixes #1420

SQLAlchemy 2.1 treats a pre-existing __dataclass_fields__ as mixed
dataclass styles, so MappedAsDataclass bases failed to construct.
@davidism davidism closed this Aug 14, 2026
@davidism

Copy link
Copy Markdown
Member

@davidism davidism changed the title Allow MappedAsDataclass model bases on SQLAlchemy 2.1 AI junk Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

SQLAlchemy 2.1 MappedAsDataclass compatibility

2 participants