flow/transfer: fix pk's not being replaced in lists
This commit is contained in:
parent
3b97389833
commit
3b6341bf41
|
@ -45,14 +45,20 @@ class FlowImporter:
|
||||||
|
|
||||||
def __update_pks_for_attrs(self, attrs: Dict[str, Any]) -> Dict[str, Any]:
|
def __update_pks_for_attrs(self, attrs: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
"""Replace any value if it is a known primary key of an other object"""
|
"""Replace any value if it is a known primary key of an other object"""
|
||||||
|
def updater(value) -> Any:
|
||||||
|
if value in self.__pk_map:
|
||||||
|
self.logger.debug(
|
||||||
|
"updating reference in entry", value=value
|
||||||
|
)
|
||||||
|
return self.__pk_map[value]
|
||||||
|
return value
|
||||||
|
|
||||||
for key, value in attrs.items():
|
for key, value in attrs.items():
|
||||||
if isinstance(value, (list, dict)):
|
if isinstance(value, (list, dict)):
|
||||||
continue
|
for idx, _inner_value in enumerate(value):
|
||||||
if value in self.__pk_map:
|
attrs[key][idx] = updater(_inner_value)
|
||||||
attrs[key] = self.__pk_map[value]
|
else:
|
||||||
self.logger.debug(
|
attrs[key] = updater(value)
|
||||||
"updating reference in entry", key=key, new_value=attrs[key]
|
|
||||||
)
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def __query_from_identifier(self, attrs: Dict[str, Any]) -> Q:
|
def __query_from_identifier(self, attrs: Dict[str, Any]) -> Q:
|
||||||
|
|
Reference in New Issue