Skip to content

FastAPI 0.67.0 new dataclass related features conflict with some aspects of new SQLAlchemy dataclass-style model mapping #6524

Discussion options

You must be logged in to vote

Interesting, I would think that the main problem here would be that SQLAlchemy supports a bit of dataclasses, but it doesn't support dataclasses.asdict() and that's where it breaks.

So, I would think that the problem is not with dataclasses, and not necessarily even with FastAPI, but with the quirk that SQLAlchemy is doing its best to support dataclasses while not being made to do so, so it can only do so much, while still modifying the class and attributes in several ways.

I see there are some possible approaches, like the __read_with_orm_mode__ attribute, maybe a ClassVar. I don't see a predefined "standard" way of modifying dataclasses with additional metadata. But the problem is that …

Replies: 17 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
8 participants
Converted from issue

This discussion was converted from issue #3616 on February 27, 2023 22:25.