For example:
from sqlmodel import Field, SQLModel, select
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, TableX.id == TableY.id)
.where(TableY.z.in_(["A", "B", "C"]))
)
We get two type errors just in this simple code:
TableX.id == TableY.id
is annotated as typebool
, which is an invalid type foronclause
injoin()
.TableY.z
is annotated as typestr
, which has no attributein_
.
The whole project I'm working on, I have to either disable my type-checker or add type: ignore
to practically every line of sqlmodel code. Are we using it wrong, or is it just not usable with type checking?