No overload variant of "select" matches argument types #1950
Replies: 5 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
)
) |
Beta Was this translation helpful? Give feedback.
-
|
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? |
Beta Was this translation helpful? Give feedback.
-
|
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()) |
Beta Was this translation helpful? Give feedback.
-
|
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() |
Beta Was this translation helpful? Give feedback.
-
|
Commenting to chime in that doing what was suggested in related PR would help me with this issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
I'm selecting multiple model attributes and calculated attributes and there is a
mypyerror:A long list of "Possible overload variants" follows.
PS.: There is no error when I
from sqlalchemy import select. Themypyerror only happens if Ifrom sqlmodel import select. In the former case, however,sqlmodel.Sessioncomplains if I use it withsqlalchemy.select.Operating System
Linux
Operating System Details
Docker image
python:3.10.2-bullseyeSQLModel Version
0.0.6
Python Version
3.10
Additional Context
Beta Was this translation helpful? Give feedback.
All reactions