Skip to content

Commit

Permalink
Merge pull request #1018 from andraghetti/missing-session-insert
Browse files Browse the repository at this point in the history
Use session in document insert
  • Loading branch information
adeelsohailahmed authored Sep 19, 2024
2 parents e10af51 + 280e92c commit 8b5446e
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 8b5446e

Please sign in to comment.