Hey guys, does SQLModel not support "Annotated + Relationship" ?
class Group(SQLModel, table=True):
"""Group Model"""
id: Annotated[int | None, Field(primary_key=True)] = None
name: Annotated[str, Field(index=True, description="Name of the group")]
# Error
# heroes: Annotated[list["Hero"], Relationship(back_populates="group")] = []
heroes: list["Hero"] = Relationship(back_populates="group")
class Hero(SQLModel, table=True):
"""Hero Model"""
id: Annotated[int | None, Field(primary_key=True)] = None
name: Annotated[str, Field(index=True, description="Name of the hero")]
group_id: Annotated[int | None, Field(foreign_key="group.id")] = None
group: Group | None = Relationship(back_populates="heroes")