Skip to content

Conversation

@AlexShein
Copy link

Hi, the statement argument type annotation of the exec method in the AsyncSession doesn't include SelectOfScalar[_T] causing mypy to complain about using await session.exec(select(Model)):

error: Argument 1 to "exec" of "AsyncSession" has incompatible type "SelectOfScalar[Model]"; expected "Union[Select[<nothing>], Executable[<nothing>]]"

Since the synchronous self.sync_session.exec is used under the hood, type annotations for the statement argument should be the same.

@github-actions
Copy link
Contributor

@antont
Copy link

antont commented May 12, 2023

Hi, just a question, if you don't mind:

We are using, with SA 1.4, session and select from there directly:

from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.future import select

is there some benefit to using them via SQLModel? I haven't noticed any problems with just using the SA ones directly. The version in SQLModel that this PR touches does not seem to do much?

@tiangolo tiangolo added the bug Something isn't working label Oct 22, 2023
@tiangolo
Copy link
Member

Thank you! This was solved in #58

The fix will be available in the next version, 0.0.9 🎉

Given that I'll close this one, but thanks for the work! ☕

@tiangolo tiangolo closed this Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants