We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Today when you have a type created from a pydantic model, you can convert it back to pydantic, but not it's fields
I made this example using sqlmodel models
from pydantic import PositiveInt from sqlmodel import ( Field, SQLModel, ) from strawberry import auto from strawberry.experimental.pydantic import input as pydantic_input class City(SQLModel): id: int | None = Field(default=None, primary_key=True) ibge: PositiveInt = Field(unique=True) name: str ddd: int | None = None class AddressBase(SQLModel): id: int | None = Field(default=None, primary_key=True) zipcode: PositiveInt | None = None neighborhood: str | None = None complement: str | None = None # coordinates: Coordinates | None = None @pydantic_input(model=City) class CityInput: ibge: auto name: auto ddd: auto @pydantic_input(model=AddressBase) class AddressInput: zipcode: auto city: CityInput | None = None address_input = AddressInput(city=CityInput(ibge=1111, name='str')) print(address_input) print(type(address_input.to_pydantic())) print(address_input.to_pydantic()) print(type(address_input.city.to_pydantic())) print(address_input.city.to_pydantic())
result:
AddressInput(city=CityInput(ibge=1111, name='str', ddd=None), zipcode=None) <class '__main__.AddressBase'> id=None zipcode=None neighborhood=None complement=None <class '__main__.City'> id=None ibge=1111 name='str' ddd=None
notice: when I print the whole address_input, it doesn't convert the field city, it's just dropped out
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Today when you have a type created from a pydantic model, you can convert it back to pydantic, but not it's fields
Describe the Bug
I made this example using sqlmodel models
result:
notice: when I print the whole address_input, it doesn't convert the field city, it's just dropped out
System Information
Upvote & Fund
The text was updated successfully, but these errors were encountered: