Open petrus-v opened 4 years ago
one solution is to avoid lazy load (using .options(contains_eager(State.device))
)
https://docs.sqlalchemy.org/en/13/orm/tutorial.html?highlight=eager#explicit-join-eagerload
one solution is to avoid lazy load (using
.options(contains_eager(State.device))
)https://docs.sqlalchemy.org/en/13/orm/tutorial.html?highlight=eager#explicit-join-eagerload
not sure it's a workaround
or make the work twice by returning schema instance MySchema.from_orm()
doing work twice ?!
I've notice this kind of errors sometimes happens while a route return an AnyBlok/SLAlchemy instance with relationship that have to be serialyzed by pydantic (through fastapi).
I belive accessing to related field with lazy load is the matter while we get an unexpected SQLA session/transaction state for some obscure reasons.