20 lines
815 B
Python
20 lines
815 B
Python
from sqlalchemy import Text, Integer, Boolean, ForeignKey
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class TestCase(Base):
|
|
__tablename__ = "test_cases"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
problem_id: Mapped[int] = mapped_column(ForeignKey("problems.id", ondelete="CASCADE"), nullable=False)
|
|
input: Mapped[str] = mapped_column(Text, nullable=False)
|
|
expected_output: Mapped[str] = mapped_column(Text, nullable=False)
|
|
is_sample: Mapped[bool] = mapped_column(Boolean, default=False) # Show in problem description
|
|
points: Mapped[int] = mapped_column(Integer, default=0)
|
|
order_index: Mapped[int] = mapped_column(Integer, default=0)
|
|
|
|
# Relationships
|
|
problem = relationship("Problem", back_populates="test_cases")
|