| 58 | |
| 59 | |
| 60 | class OrderItem(Base): |
| 61 | __tablename__ = "orderitem" |
| 62 | order_id: Mapped[int] = mapped_column( |
| 63 | ForeignKey("order.order_id"), primary_key=True |
| 64 | ) |
| 65 | item_id: Mapped[int] = mapped_column( |
| 66 | ForeignKey("item.item_id"), primary_key=True |
| 67 | ) |
| 68 | price: Mapped[float] |
| 69 | |
| 70 | item: Mapped[Item] = relationship(lazy="joined") |
| 71 | |
| 72 | def __init__(self, item: Item, price: float | None = None): |
| 73 | self.item = item |
| 74 | self.price = price or item.price |
| 75 | |
| 76 | |
| 77 | if __name__ == "__main__": |
no test coverage detected