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

✨ Add support for passing a custom SQLAlchemy type to `Field()` with `sa_type` by maru0123-2004 · Pull Request #505 · fastapi/sqlmodel · GitHub

Repository navigation

✨ Add support for passing a custom SQLAlchemy type to Field() with sa_type - #505

Merged
tiangolo merged 13 commits into
fastapi:mainfrom
maru0123-2004:main
Oct 29, 2023
Merged

tiangolo merged 13 commits into
fastapi:mainfrom
maru0123-2004:main

Conversation

maru0123-2004 commented Nov 23, 2022 •
edited by tiangolo
Loading

Copy link
Copy Markdown
Contributor

Related to #503 .

Notice;
I tested its works only in my case.

maru0123-2004 changed the title Add sa_type to Field to Add sa_type to Field to fix #503 Nov 23, 2022

Copy link
Copy Markdown
Contributor

📝 Docs preview for commit 55098b2 at: https://637da5945b0a220ff8ef4e3c--sqlmodel.netlify.app

Copy link
Copy Markdown
Contributor

📝 Docs preview for commit c4c58cc at: https://6399e5912bd3820502950046--sqlmodel.netlify.app

Copy link
Copy Markdown
Contributor

📝 Docs preview for commit 54d1816 at: https://639cdfbd569504009f94aa64--sqlmodel.netlify.app

Copy link
Copy Markdown

I just started trying out SQLModel and hit the issue where I can't use a JSON sqlalchemy type, so fixing and merging this PR would be very useufl.

Copy link
Copy Markdown
Contributor Author

Thank you...!
Is there any error...?

bkanuka commented Feb 19, 2023

Copy link
Copy Markdown

FWIW I personally prefer some of the solutions outlined in #503 (adding an override) rather than just adding sa_type. The ideas in #503 have the potential to be more general and helpful in more situations.

farzadsbakhtiar commented Jun 20, 2023 •
edited
Loading

Copy link
Copy Markdown

@danielkza you can do something like this:

from sqlmodel import Column, JSON

class Model(SQLModel):
    # -- adapt field type according to your needs
    subject_sids: dict[str, str] = Field(sa_column=Column(JSON))

tiangolo added the feature New feature or request label Oct 22, 2023
tiangolo changed the title Add sa_type to Field to fix #503 ✨ Add support for passing a custom SQLAlchemy type to Field() with sa_type Oct 29, 2023

Copy link
Copy Markdown
Member

Great, thank you @maru0123-2004! 🚀 🍰

This will be available in the next version, 0.0.11 🎉

I will document it (and add tests for it) soon, but later, after migrating to SQLAlchemy 2.0 and Pydantic 2.0. 🤓

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

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL