You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
Sync should refresh linked values as well.
It can be done by changing merge_models function,
Or by passing fetch_links, with_children, nesting_depth, nesting_depths_per_field fields to sync function that should be propagated to document = await self.find_one({"_id": self.id})
Additional context
This is because it uses merge_models function:
beanie/odm/utils/parsing.py
defmerge_models(left: BaseModel, right: BaseModel) ->None:
""" Merge two models :param left: left model :param right: right model :return: None """frombeanie.odm.fieldsimportLinkfork, right_valueinright.__iter__():
left_value=getattr(left, k)
ifisinstance(right_value, BaseModel) andisinstance(
left_value, BaseModel
):
ifget_config_value(left_value, "frozen"):
left.__setattr__(k, right_value)
else:
merge_models(left_value, right_value)
continueifisinstance(right_value, list):
links_found=Falseforiinright_value:
ifisinstance(i, Link):
links_found=Truebreakiflinks_found:
continueleft.__setattr__(k, right_value)
elifnotisinstance(right_value, Link):
left.__setattr__(k, right_value)
The text was updated successfully, but these errors were encountered:
Describe the bug
Document.sync() method doesn't sync
Link
fields.To Reproduce
Expected behavior
Sync should refresh linked values as well.
It can be done by changing
merge_models
function,Or by passing fetch_links, with_children, nesting_depth, nesting_depths_per_field fields to
sync
function that should be propagated todocument = await self.find_one({"_id": self.id})
Additional context
This is because it uses
merge_models
function:beanie/odm/utils/parsing.py
The text was updated successfully, but these errors were encountered: