First Check
Commit to Help
Example Code
@router.get("/user/", response_model=List[UserReadWithClients])
async def user(limit: int = 10, offset: int=0 ):
with Session(get_engine()) as session:
statement = select(User).offset(offset).limit(limit).options(subqueryload(User.clients))
results = session.exec(statement).all()
return results
Description
I followed the Hero and Team sample it works well but I have a many to many relationship and I get the following message
Parent instance <User at 0x22b6878e880> is not bound to a Session; lazy load operation of attribute 'clients' cannot proceed
I use the sqlAlchem,y orm subquery load option to fix my problem but what is the proper SQLmodel approach for many to many?
(Since it works transparently for 1 to many relationships)
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.9.7
Additional Context
No response
First Check
Commit to Help
Example Code
Description
I followed the Hero and Team sample it works well but I have a many to many relationship and I get the following message
Parent instance <User at 0x22b6878e880> is not bound to a Session; lazy load operation of attribute 'clients' cannot proceed
I use the sqlAlchem,y orm subquery load option to fix my problem but what is the proper SQLmodel approach for many to many?
(Since it works transparently for 1 to many relationships)
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.9.7
Additional Context
No response