forked from platypush/platypush
Make the recursive entity merger/column set logic more resilient against ObjectDeletedError
This commit is contained in:
parent
98a300c4b1
commit
d473b5d836
1 changed files with 11 additions and 1 deletions
|
@ -1,11 +1,15 @@
|
|||
import logging
|
||||
from typing import Iterable, List, Optional
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.orm.exc import ObjectDeletedError
|
||||
|
||||
from platypush.entities._base import Entity, EntityMapping
|
||||
|
||||
from .helpers import get_parent
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class EntitiesMerger:
|
||||
|
@ -180,7 +184,13 @@ class EntitiesMerger:
|
|||
**(entity.meta or {}), # type: ignore
|
||||
}
|
||||
elif col not in ('id', 'created_at'):
|
||||
setattr(existing_entity, col, getattr(entity, col))
|
||||
try:
|
||||
setattr(existing_entity, col, getattr(entity, col))
|
||||
except ObjectDeletedError as e:
|
||||
logger.warning(
|
||||
'Could not set %s on entity <%s>: %s',
|
||||
col, existing_entity.entity_key, e
|
||||
)
|
||||
|
||||
# Recursive call to merge the columns of the children too
|
||||
if include_children:
|
||||
|
|
Loading…
Reference in a new issue