Replies: 4 comments
-
I'll happily contribute some docs around typing if there is a blessed way forward we can get working |
Beta Was this translation helpful? Give feedback.
-
You should use select(Model).where(col(Model.deleted_at).is_(None)) |
Beta Was this translation helpful? Give feedback.
-
Thanks for this clarification, I missed that from the documentation. However, It’s not very convenient having to use a function (such as col) to make it work. It feels broken. On top of that, this trick does not work when calling I would expect this to work out of the box without having to rely on additional function that adds noises to the code, nor adding |
Beta Was this translation helpful? Give feedback.
-
I've been struggling with this too - instead of using My hacky work around for now has been:
and then including that in the annotations on models like in vanilla SQLAlchemy. That satisfies type checkers and still works at runtime because Pydantic/SQLmodel/etc just see the inner type hint. I played around with setting up a Pydantic |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
SQLModel doesn't support type-checking when using the
select
query syntax likeis_
:Error (Pylance)
When not using something like
Mapped
, typechecking fails:Error (pydantic v1)
When using pydantic v1 and
from sqlalchemy.orm import Mapped
Error (pydantic v2)
When using pydantic v2 and
from sqlalchemy.orm import Mapped
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.19
Python Version
Python 3.12.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions