-
-
Notifications
You must be signed in to change notification settings - Fork 684
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
🐛 Fix AsyncSession
type annotations for exec()
#58
Conversation
894c60d
to
8d578a9
Compare
Thanks for the feature! Until this PR gets merged, manually patching will work for my workflow. |
📝 Docs preview for commit 11ff44f at: https://639cfc052b35ad15e2e48091--sqlmodel.netlify.app |
@tiangolo, I can try to resolve CI issues and update the branch, but I need a confirmation that you have intention of merging it once issues are resolved and willing to communicate if I'll need any feedback on resolving them. Complete lack of comminucation from your side on this issue is frustrating. I don't want to waste any more time on this PR only to find it in the same condition a year later. |
Thanks @Bobronium for the fix, I am pip installing your branch instead of v0.0.8. I hope this gets merged soon. |
Crazy this has been around since 2021. Awesome work @Bobronium on this. |
The whole point of SQLModel is that it returns typed objects that play nice with Pydantic and allow your editor's autocomplete functions to work properly. Except when you're using `sqlalchemy.AsyncSession`, it... doesn't. And there *is* a `sqlmodel.AsyncSession`, but it's broken. And there is a *fix* for it in an upstream PR, but it's not merged yet. fastapi/sqlmodel#58 This PR just copies and uses the upstream PR implementation of `sqlmodel.AsyncSession`. Most of the actual diff here is related to the side-benefit that we no longer have to unwrap the row-tuples that `sqlalchemy.execute` returns, but most of the actual benefit for doing this is that we'll now actually get our appropriately-typed model objects back out of `session.exec` instead of `Any`. Related work items: #15767106
Please merge this? |
@tiangolo, I've fixed CI issue. Tests are passing now. Please merge. |
Great, thanks @Bobronium! 🚀 Thanks everyone for the comments, in particular confirming this solved it for you. 🍰 Thanks for the patience everyone! This will be available in the next version, |
AsyncSession
type annotations for exec()
# What This updates SQLModel to version 0.0.11, which solves an [issue](fastapi/sqlmodel#443) with foreign key declaration, and another [issue](fastapi/sqlmodel#58) with AsyncSession type annotations. # Why Prior to this update, attempting to delete a document with an associated index record would throw a foreign key violation error. # Test plan Add a document which results in an index record being created. Delete the same document and verify that - The document is deleted without error - The index records associated with the document are also deleted
Fixes #54
hero.py
:Running on main
Running on Bobronium:AsyncSession_typing_fix: