from typing import Optional
from sqlmodel import Field, SQLModel, Relationship, Column
from sqlalchemy_utils.types import TSVectorType
from .db import stand_by_models, stand_by_db


stand_by_models()


class Hero(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    content: str
    age: Optional[int] = None
    search_vector: Optional[str] = Field(
        sa_column=Column(
            TSVectorType(
                "name",
                "content",
                # weights={"name": "A", "secret_name": "B", "age": "D"},
            )
        )
    )


class Parents(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    # children = orm.relationship("Children")


class Children(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    parent_id: Optional[int] = Field(default=None, foreign_key="parents.id")


stand_by_db()

sqlalchemy_utils.types.TSVectorType sqlmodel.Field
[((260, 297), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (265, 297), False, 'from sqlmodel import Field, SQLModel, Relationship, Column\n'), ((670, 707), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (675, 707), False, 'from sqlmodel import Field, SQLModel, Relationship, Column\n'), ((832, 869), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (837, 869), False, 'from sqlmodel import Field, SQLModel, Relationship, Column\n'), ((915, 960), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'foreign_key': '"""parents.id"""'}), "(default=None, foreign_key='parents.id')\n", (920, 960), False, 'from sqlmodel import Field, SQLModel, Relationship, Column\n'), ((439, 470), 'sqlalchemy_utils.types.TSVectorType', 'TSVectorType', (['"""name"""', '"""content"""'], {}), "('name', 'content')\n", (451, 470), False, 'from sqlalchemy_utils.types import TSVectorType\n')]