Skip to content

Commit 4d13aa3

Browse files
committed
Add _Executable overload for exec method in AsyncSession and Session
1 parent 6c0410e commit 4d13aa3

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

sqlmodel/ext/asyncio/session.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,33 @@ async def exec(
5757
_add_event: Optional[Any] = None,
5858
) -> ScalarResult[_TSelectParam]: ...
5959

60+
@overload
61+
async def exec(
62+
self,
63+
statement: _Executable,
64+
*,
65+
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
66+
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
67+
bind_arguments: Optional[Dict[str, Any]] = None,
68+
_parent_execute_state: Optional[Any] = None,
69+
_add_event: Optional[Any] = None,
70+
) -> Result[Any]: ...
71+
6072
async def exec(
6173
self,
6274
statement: Union[
6375
Select[_TSelectParam],
6476
SelectOfScalar[_TSelectParam],
6577
Executable[_TSelectParam],
78+
_Executable,
6679
],
6780
*,
6881
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
6982
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
7083
bind_arguments: Optional[Dict[str, Any]] = None,
7184
_parent_execute_state: Optional[Any] = None,
7285
_add_event: Optional[Any] = None,
73-
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam]]:
86+
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam], Result[Any]]:
7487
if execution_options:
7588
execution_options = util.immutabledict(execution_options).union(
7689
_EXECUTE_OPTIONS

sqlmodel/orm/session.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,33 @@ def exec(
4949
_add_event: Optional[Any] = None,
5050
) -> ScalarResult[_TSelectParam]: ...
5151

52+
@overload
53+
def exec(
54+
self,
55+
statement: _Executable,
56+
*,
57+
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
58+
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
59+
bind_arguments: Optional[Dict[str, Any]] = None,
60+
_parent_execute_state: Optional[Any] = None,
61+
_add_event: Optional[Any] = None,
62+
) -> Result[Any]: ...
63+
5264
def exec(
5365
self,
5466
statement: Union[
5567
Select[_TSelectParam],
5668
SelectOfScalar[_TSelectParam],
5769
Executable[_TSelectParam],
70+
_Executable,
5871
],
5972
*,
6073
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
6174
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
6275
bind_arguments: Optional[Dict[str, Any]] = None,
6376
_parent_execute_state: Optional[Any] = None,
6477
_add_event: Optional[Any] = None,
65-
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam]]:
78+
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam], Result[Any]]:
6679
results = super().execute(
6780
statement,
6881
params=params,

0 commit comments

Comments
 (0)