From 1c811a490f8f6b49d29bddace62ca863d6d1f9ae Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 1 Jan 2023 12:47:15 +0100 Subject: [PATCH] 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. --- platypush/entities/_base.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platypush/entities/_base.py b/platypush/entities/_base.py index 988ea4b3..731f3bc9 100644 --- a/platypush/entities/_base.py +++ b/platypush/entities/_base.py @@ -112,9 +112,7 @@ if 'entity' not in Base.metadata: return val def to_json(self) -> dict: - obj = {col.key: self._serialize_value(col) for col in self.columns} - obj['children_ids'] = [e.id for e in self.children] - return obj + return {col.key: self._serialize_value(col) for col in self.columns} def __repr__(self): return str(self)