FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

🐛 Fix enum type checks ordering in `get_sqlalchemy_type` by tiangolo · Pull Request #669 · fastapi/sqlmodel · GitHub

Repository navigation

🐛 Fix enum type checks ordering in get_sqlalchemy_type - #669

Merged
tiangolo merged 3 commits into
mainfrom
pr/pierrecdn/442
Oct 23, 2023
Merged

tiangolo merged 3 commits into
mainfrom
pr/pierrecdn/442

Conversation

tiangolo commented Oct 23, 2023 •
edited
Loading

Copy link
Copy Markdown
Member

🐛 Fix enum type checks ordering in get_sqlalchemy_type

This continues the work in #442 by @pierrecdn as I can't push to the original branch, but it includes his commits. 🤓

pierrecdn and others added 3 commits September 9, 2022 00:10
When enum subclassing/mix-in[1] is used, especially to ensure compatibility
and produce correct OpenAPI specifications with FastAPI[2], SQLModel on its
side doesn't map to the correct SQLAlchemy type.

e.g.:
* `class Foo(Enum)` will work but won't allow a proper OpenAPI spec. to be
generated.
* `class Foo(str, Enum)` will fix the previous situation, but prevents
SQLModel to read and map the object from the DB (due to validation errors).

Changing ordering of checks to ensure that Enum subclasses are tested first.

[1] https://docs.python.org/3/library/enum.html#restricted-enum-subclassing
[2] https://fastapi.tiangolo.com/sq/tutorial/path-params/#create-an-enum-class
tiangolo merged commit d3261ca into main Oct 23, 2023
tiangolo deleted the pr/pierrecdn/442 branch October 23, 2023 09:22

Copy link
Copy Markdown
Member Author

This will be available in the next release, 0.0.9. 🎉

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL