from typing import List, Optional

from sqlmodel import Field, Relationship, SQLModel


class Sport(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    athletes: List["Athlete"] = Relationship(back_populates="sport")


class Athlete(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    sport_id: Optional[int] = Field(default=None, foreign_key="sport.id")
    sport: Optional[Sport] = Relationship(back_populates="athletes")

sqlmodel.Relationship sqlmodel.Field
[((147, 184), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (152, 184), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((231, 267), 'sqlmodel.Relationship', 'Relationship', ([], {'back_populates': '"""sport"""'}), "(back_populates='sport')\n", (243, 267), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((331, 368), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (336, 368), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((413, 456), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'foreign_key': '"""sport.id"""'}), "(default=None, foreign_key='sport.id')\n", (418, 456), False, 'from sqlmodel import Field, Relationship, SQLModel\n'), ((486, 525), 'sqlmodel.Relationship', 'Relationship', ([], {'back_populates': '"""athletes"""'}), "(back_populates='athletes')\n", (498, 525), False, 'from sqlmodel import Field, Relationship, SQLModel\n')]