Don't serialize children_ids in Entity.to_json()

Serializing both children_ids and parent_id can result in nasty
SQLAlchemy bugs, especially when handling objects that haven't been
flushed yet.
This commit is contained in:
Fabio Manganiello 2023-01-01 12:47:15 +01:00
parent f9b6799a18
commit 1c811a490f
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -112,9 +112,7 @@ if 'entity' not in Base.metadata:
return val return val
def to_json(self) -> dict: def to_json(self) -> dict:
obj = {col.key: self._serialize_value(col) for col in self.columns} return {col.key: self._serialize_value(col) for col in self.columns}
obj['children_ids'] = [e.id for e in self.children]
return obj
def __repr__(self): def __repr__(self):
return str(self) return str(self)