Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Pydantic Json type for JSON or JSONB in create_pydantic_model #48

Closed
heliumbrain opened this issue Jun 27, 2021 · 2 comments
Closed

Comments

@heliumbrain
Copy link
Contributor

Example table:

class Recipe(Table):
    name: str = Varchar(length=100)
    content: str = Text()
    author: BaseUser = ForeignKey(references=BaseUser)
    category: str = Varchar(length=50)
    ingredients: List = JSONB()
    extras: Dict = JSON()

Currently, any JSON and JSONB fields from a Piccolo Table is being serialized as strings. It technically works, but parsing it as a string outputs this:

Screenshot 2021-06-27 at 15 02 44

Setting value_type = pydantic.Json for JSON and JSONB fields makes it look a lot better:

Screenshot 2021-06-27 at 15 01 56

@heliumbrain
Copy link
Contributor Author

Added a PR for this here: #49 - Not sure how to link them properly in Github.. Only maintainers can do that maybe? 😕

@heliumbrain
Copy link
Contributor Author

PR merged, closing this

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

No branches or pull requests

1 participant