Skip to content

Commit

Permalink
Use session in document insert
Browse files Browse the repository at this point in the history
  • Loading branch information
andraghetti committed Sep 5, 2024
1 parent ca585b1 commit 280e92c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions beanie/odm/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,20 @@ async def insert(
LinkTypes.OPTIONAL_DIRECT,
]:
if isinstance(value, Document):
await value.save(link_rule=WriteRules.WRITE)
await value.save(
link_rule=WriteRules.WRITE, session=session
)
if field_info.link_type in [
LinkTypes.LIST,
LinkTypes.OPTIONAL_LIST,
]:
if isinstance(value, List):
await asyncio.gather(
*[
obj.save(link_rule=WriteRules.WRITE)
obj.save(
link_rule=WriteRules.WRITE,
session=session,
)
for obj in value
if isinstance(obj, Document)
]
Expand Down

0 comments on commit 280e92c

Please sign in to comment.