From 8364a704d6c14fc0b468c3dfce7245aeb994a7e0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 12 Feb 2024 20:31:44 +0100 Subject: [PATCH] Fix a few sql gotchas --- freqtrade/persistence/custom_data.py | 1 + freqtrade/persistence/trade_model.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/freqtrade/persistence/custom_data.py b/freqtrade/persistence/custom_data.py index e8fa0d960..bf72510be 100644 --- a/freqtrade/persistence/custom_data.py +++ b/freqtrade/persistence/custom_data.py @@ -24,6 +24,7 @@ class _CustomData(ModelBase): - One metadata entry can only be associated with one Trade """ __tablename__ = 'trade_custom_data' + __allow_unmapped__ = True session: ClassVar[SessionType] # Uniqueness should be ensured over pair, order_id diff --git a/freqtrade/persistence/trade_model.py b/freqtrade/persistence/trade_model.py index 55a075cc9..1aa7cb607 100644 --- a/freqtrade/persistence/trade_model.py +++ b/freqtrade/persistence/trade_model.py @@ -1485,7 +1485,7 @@ class Trade(ModelBase, LocalTrade): "Order", order_by="Order.id", cascade="all, delete-orphan", lazy="selectin", innerjoin=True) # type: ignore custom_data: Mapped[List[_CustomData]] = relationship( - "CustomData", order_by="CustomData.id", cascade="all, delete-orphan", + "_CustomData", cascade="all, delete-orphan", lazy="raise") # type: ignore exchange: Mapped[str] = mapped_column(String(25), nullable=False) # type: ignore