Fix broken deletion

This commit is contained in:
Matthias
2024-02-12 20:51:44 +01:00
parent 1c81a21bb6
commit 6a6e3aacf3
2 changed files with 5 additions and 2 deletions

View File

@@ -96,6 +96,10 @@ class CustomDataWrapper:
if not CustomDataWrapper.use_db:
CustomDataWrapper.custom_data = []
@staticmethod
def delete_custom_data(trade_id: int) -> None:
_CustomData.session.query(_CustomData).filter(_CustomData.ft_trade_id == trade_id).delete()
@staticmethod
def get_custom_data(key: Optional[str] = None,
trade_id: Optional[int] = None) -> List[_CustomData]:

View File

@@ -1600,8 +1600,7 @@ class Trade(ModelBase, LocalTrade):
for order in self.orders:
Order.session.delete(order)
for entry in self.custom_data:
_CustomData.session.delete(entry)
CustomDataWrapper.delete_custom_data(trade_id=self.id)
_CustomData.session.commit()
Trade.session.delete(self)