Skip to content

Commit

Permalink
Fix relationship copy warning (#2614)(patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
seallard authored Oct 27, 2023
1 parent 4ed7a42 commit f5bde2c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cg/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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})"
Expand Down

0 comments on commit f5bde2c

Please sign in to comment.