79709420

Date: 2025-07-21 17:21:11
Score: 0.5
Natty:
Report link

If you import col from sqlmodel and wrap the relevant columns with col, the type errors should disappear, at least for the ones in your example:


from sqlmodel import Field, SQLModel, select, col


class TableX(SQLModel, table=True):
    id: int | None = Field(default=None, primary_key=True)
    x: str


class TableY(SQLModel, table=True):
    id: int
    y: str
    z: str


query = (
    select(TableX)
    .join(TableY, col(TableX.id) == col(TableY.id))
    .where(col(TableY.z).in_(["A", "B", "C"]))
)

See:

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Aly