FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

✨ Add overload for `exec` method to support `insert`, `update`, `delete` statements by seriaati · Pull Request #1342 · fastapi/sqlmodel · GitHub

Repository navigation

✨ Add overload for exec method to support insert, update, delete statements - #1342

Merged
tiangolo merged 6 commits into
fastapi:mainfrom
seriaati:main
Sep 17, 2025
Merged

tiangolo merged 6 commits into
fastapi:mainfrom
seriaati:main

Conversation

Copy link
Copy Markdown
Contributor

To address #909

seriaati changed the title Add _Executable overload for exec method in AsyncSession and Session ✨ Add _Executable overload for exec method in AsyncSession and Session Apr 10, 2025
seriaati marked this pull request as draft April 10, 2025 01:21
seriaati changed the title ✨ Add _Executable overload for exec method in AsyncSession and Session ✨ Add UpdateBase overload for exec method in AsyncSession and Session Apr 10, 2025
seriaati marked this pull request as ready for review April 10, 2025 01:31
svlandeg added the feature New feature or request label Apr 10, 2025

superboum commented Jun 3, 2025 •
edited
Loading

Copy link
Copy Markdown

On #1349 you asked for feedbacks on your PR: I tested it and it fixed my typing errors!

Previously I had this mypy output:

src/ddd/infrastructure/manager.py:263: error: No overload variant of "exec" of "Session" matches argument type "Update"  [call-overload]
src/ddd/infrastructure/manager.py:263: note: Possible overload variants:
src/ddd/infrastructure/manager.py:263: note:     def [_TSelectParam: Any] exec(self, statement: Select[_TSelectParam], *, params: Mapping[str, Any] | Sequence[Mapping[str, Any]] | None = ..., execution_options: Mapping[str, Any] = ..., bind_arguments: dict[str, Any] | None = ..., _parent_execute_state: Any | None = ..., _add_event: Any | None = ...) -> TupleResult[_TSelectParam]
src/ddd/infrastructure/manager.py:263: note:     def [_TSelectParam: Any] exec(self, statement: SelectOfScalar[_TSelectParam], *, params: Mapping[str, Any] | Sequence[Mapping[str, Any]] | None = ..., execution_options: Mapping[str, Any] = ..., bind_arguments: dict[str, Any] | None = ..., _parent_execute_state: Any | None = ..., _add_event: Any | None = ...) -> ScalarResult[_TSelectParam]

After applying your patch, the type error is solved.
Thanks a lot, hope your patch will be merged soon so everyone can benefit from this typing fix in sqlmodel 🌟

Copy link
Copy Markdown

Hope this gets merged soon! Good job @seriaati

YuriiMotov changed the title ✨ Add UpdateBase overload for exec method in AsyncSession and Session ✨ Add overload for exec method to support insert, update, delete statements Aug 15, 2025

YuriiMotov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM!

This fixes the typing issue when we use exec method with insert, update or delete statements. Currently it works, but type checkers raise warnings. This PR fixes this.

@seriaati, thanks for working on this!

tiangolo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @seriaati! 🚀

This will be available in SQLModel 0.0.25, released in the next few hours. 🎉

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an overload to the exec method with _Executable statement for update and delete statements

6 participants


Back | FazBrowse Home | New Git URL