You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to keep the result annotation (->list[StrategyWithPortfolios]:) it seems to work. Also needed for the openapi.json to report the correct result type (instead of juststr).
Tested on FastAPI version 0.115.0.
Would be super nice if the worked without having to specify response model twise.
Just found that this is reported here as well #384
See here:
https://sqlmodel.tiangolo.com/tutorial/fastapi/relationships/#models-with-relationships
My example code
The returned result is sqlalchemy orm class
Strategy
but the data structure I want to return isStrategyWithPortfolios
.The code works well without the line
ret = [StrategyWithPortfolios.model_validate(r) for r in ret]
and@cache(expire=60)
.But if I add
@cache(expire=60)
it save fields only belong toStrategy
notportfolios
norCategory
to redis.Please serialize the returned result to given pydantic model before save it to backend.
The text was updated successfully, but these errors were encountered: