-
-
Notifications
You must be signed in to change notification settings - Fork 715
No overload variant of "select" matches argument types #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have similar errors:
line 124: select(GameSession.user_won, func.count()) line 147: session.exec(func.avg(avg_query.subquery().c.count)) line 151: session.exec(
func.avg(
avg_query.filter(GameSession.user_won == True)
.subquery()
.c.count
)
) |
You guys are not alone. Only solution at the moment: import Any other solution found yet? Or is the way of doing things here not the way it should be? |
To anyone who comes across this issue as I did, the solution apparently is to wrap column expressions with the For example: from sqlmodel import col
...
select(col(GameSession.user_won), func.count()) |
I'm running into this issue as well. For me, and the OP, this appears to be caused by having "too many" arguments, where "too many" is > 4 since the Looking at the implementation of query: Select[tuple[ModelA, int, int, int, int]] = (
Select(
Model,
col(subquery.c.a), # These subquery columns are all from `func.count`
col(subquery.c.b),
col(subquery.c.c),
col(subquery.c.d),
).join(...)
r = session.exec(query).all() |
First Check
Commit to Help
Example Code
Description
I'm selecting multiple model attributes and calculated attributes and there is a
mypy
error:A long list of "Possible overload variants" follows.
PS.: There is no error when I
from sqlalchemy import select
. Themypy
error only happens if Ifrom sqlmodel import select
. In the former case, however,sqlmodel.Session
complains if I use it withsqlalchemy.select
.Operating System
Linux
Operating System Details
Docker image
python:3.10.2-bullseye
SQLModel Version
0.0.6
Python Version
3.10
Additional Context
The text was updated successfully, but these errors were encountered: