From 3272557df7223cd0ec01c2ab6237570a599d348e Mon Sep 17 00:00:00 2001 From: skipper70 <5059499+skipper70@users.noreply.github.com> Date: Sun, 2 May 2021 07:44:45 +0500 Subject: [PATCH] fix order-transaction one-to-one relation #2 --- database.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database.py b/database.py index 671afca..a1ece93 100644 --- a/database.py +++ b/database.py @@ -181,6 +181,7 @@ class Transaction(DeferredReflection, TableDeclarativeBase): # Order ID order_id = Column(Integer, ForeignKey("orders.order_id")) + order = relationship("Order", back_populates="transaction") # Extra table parameters __tablename__ = "transactions" @@ -244,7 +245,7 @@ class Order(DeferredReflection, TableDeclarativeBase): # Extra details specified by the purchasing user notes = Column(Text) # Linked transaction - transaction = relationship("Transaction", backref="order", uselist=False) + transaction = relationship("Transaction", back_populates="order", uselist=False) # Extra table parameters __tablename__ = "orders"