Reconfigure relationships to squelch sqla warnings

We only ever create new records/relationships by linking up IDs
explicitly (rather than, say, appending them to a relationship), so we
can safely set viewonly=True on most relationsihps.
This commit is contained in:
Drew DeVault 2021-07-26 11:21:18 +02:00
parent 6aef73b2c7
commit cb9a219e58
2 changed files with 7 additions and 4 deletions

View File

@ -19,7 +19,8 @@ class Label(Base):
color = sa.Column(sa.Text, nullable=False)
text_color = sa.Column(sa.Text, nullable=False)
tickets = sa.orm.relationship("Ticket", secondary="ticket_label")
tickets = sa.orm.relationship("Ticket",
secondary="ticket_label", viewonly=True)
__table_args__ = (
sa.UniqueConstraint("tracker_id", "name",

View File

@ -57,14 +57,16 @@ class Ticket(Base):
anonymous_perms = sa.Column(FlagType(TicketAccess), nullable=True)
"""Permissions granted to anonymous (non-logged in) users"""
view_list = sa.orm.relationship("TicketSeen")
view_list = sa.orm.relationship("TicketSeen", viewonly=True)
labels = sa.orm.relationship("Label",
secondary="ticket_label", order_by="Label.name")
secondary="ticket_label", order_by="Label.name",
viewonly=True)
assigned_users = sa.orm.relationship("User",
secondary="ticket_assignee",
foreign_keys="[TicketAssignee.ticket_id,TicketAssignee.assignee_id]")
foreign_keys="[TicketAssignee.ticket_id,TicketAssignee.assignee_id]",
viewonly=True)
authenticity = sa.Column(
sau.ChoiceType(TicketAuthenticity, impl=sa.Integer()),