Coverage for polar/models/product_custom_field.py: 88%
15 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
1from typing import TYPE_CHECKING
2from uuid import UUID
4from sqlalchemy import ForeignKey, UniqueConstraint, Uuid
5from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship
7from polar.custom_field.attachment import AttachedCustomFieldMixin
8from polar.kit.db.models import RecordModel
10if TYPE_CHECKING: 10 ↛ 11line 10 didn't jump to line 11 because the condition on line 10 was never true
11 from polar.models import Product
14class ProductCustomField(AttachedCustomFieldMixin, RecordModel):
15 __tablename__ = "product_custom_fields"
16 __table_args__ = (UniqueConstraint("product_id", "order"),)
18 product_id: Mapped[UUID] = mapped_column(
19 Uuid,
20 ForeignKey("products.id", ondelete="cascade"),
21 primary_key=True,
22 )
24 @declared_attr
25 def product(cls) -> Mapped["Product"]:
26 return relationship(
27 "Product", lazy="raise", back_populates="attached_custom_fields"
28 )