From f5bde2c27d31666c4b688715291bd8f21b854768 Mon Sep 17 00:00:00 2001 From: Sebastian Allard Date: Fri, 27 Oct 2023 12:13:18 +0100 Subject: [PATCH] Fix relationship copy warning (#2614)(patch) --- cg/store/models.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cg/store/models.py b/cg/store/models.py index 8a687a0f9e..85dc9f3f91 100644 --- a/cg/store/models.py +++ b/cg/store/models.py @@ -316,7 +316,13 @@ class Customer(Model): data_archive_location = Column(types.String(32), nullable=False, default="PDC") is_clinical = Column(types.Boolean, nullable=False, default=False) - collaborations = orm.relationship("Collaboration", secondary=customer_collaboration) + collaborations = orm.relationship( + "Collaboration", + secondary="customer_collaboration", + back_populates="customers", + cascade_backrefs=False, + ) + delivery_contact_id = Column(ForeignKey("user.id")) delivery_contact = orm.relationship("User", foreign_keys=[delivery_contact_id]) invoice_contact_id = Column(ForeignKey("user.id")) @@ -352,7 +358,12 @@ class Collaboration(Model): id = Column(types.Integer, primary_key=True) internal_id = Column(types.String(32), unique=True, nullable=False) name = Column(types.String(128), nullable=False) - customers = orm.relationship(Customer, secondary=customer_collaboration) + customers = orm.relationship( + "Customer", + secondary="customer_collaboration", + back_populates="collaborations", + cascade_backrefs=False, + ) def __str__(self) -> str: return f"{self.internal_id} ({self.name})"