Skip to content

Conversation

@maru0123-2004
Copy link
Contributor

@maru0123-2004 maru0123-2004 commented Nov 23, 2022

Related to #503 .

Notice;
I tested its works only in my case.

@maru0123-2004 maru0123-2004 changed the title Add sa_type to Field to Nov 23, 2022
@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@danielkza
Copy link

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.

@maru0123-2004
Copy link
Contributor Author

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

@bkanuka
Copy link

bkanuka commented Feb 19, 2023

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
Copy link

farzadsbakhtiar commented Jun 20, 2023

@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 tiangolo added the feature New feature or request label Oct 22, 2023
@tiangolo tiangolo changed the title Add sa_type to Field to fix #503 Oct 29, 2023
@tiangolo
Copy link
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. 🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

5 participants