Skip to content

Fix lazy load crash async#1

Closed
yenchenLiu wants to merge 1 commit intoArcLightSlavik:async_sqlalchemyfrom
yenchenLiu:fix_async_sqlalchemy
Closed

Fix lazy load crash async#1
yenchenLiu wants to merge 1 commit intoArcLightSlavik:async_sqlalchemyfrom
yenchenLiu:fix_async_sqlalchemy

Conversation

@yenchenLiu
Copy link
Copy Markdown

Due to lazy load make async not work, I change the mode from lazy(select) loading to select in loading https://docs.sqlalchemy.org/en/14/orm/loading_relationships.html

In this way, there is no need to query again. But at the same time, if we don't need relationships, it is a waste.

https://docs.sqlalchemy.org/en/14/orm/extensions/asyncio.html#synopsis-orm

And I didn't think there is other ways to solve this problem currently.

@yenchenLiu
Copy link
Copy Markdown
Author

Another option is only use in specific query, but still need to pay attention to whether the schema uses lazy loading.
stmt = select(A).options(selectinload(A.bs))

@ArcLightSlavik
Copy link
Copy Markdown
Owner

Should be fixed

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

Successfully merging this pull request may close these issues.

2 participants