Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add _Executable overload for exec method in AsyncSession and Session
  • Loading branch information
seriaati committed Apr 10, 2025
commit 4d13aa3da572837b1203720b2d18879b74c6f604
15 changes: 14 additions & 1 deletion sqlmodel/ext/asyncio/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,33 @@ async def exec(
_add_event: Optional[Any] = None,
) -> ScalarResult[_TSelectParam]: ...

@overload
async def exec(
self,
statement: _Executable,
*,
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
bind_arguments: Optional[Dict[str, Any]] = None,
_parent_execute_state: Optional[Any] = None,
_add_event: Optional[Any] = None,
) -> Result[Any]: ...

async def exec(
self,
statement: Union[
Select[_TSelectParam],
SelectOfScalar[_TSelectParam],
Executable[_TSelectParam],
_Executable,
],
*,
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
bind_arguments: Optional[Dict[str, Any]] = None,
_parent_execute_state: Optional[Any] = None,
_add_event: Optional[Any] = None,
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam]]:
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam], Result[Any]]:
if execution_options:
execution_options = util.immutabledict(execution_options).union(
_EXECUTE_OPTIONS
Expand Down
15 changes: 14 additions & 1 deletion sqlmodel/orm/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,33 @@ def exec(
_add_event: Optional[Any] = None,
) -> ScalarResult[_TSelectParam]: ...

@overload
def exec(
self,
statement: _Executable,
*,
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
bind_arguments: Optional[Dict[str, Any]] = None,
_parent_execute_state: Optional[Any] = None,
_add_event: Optional[Any] = None,
) -> Result[Any]: ...

def exec(
self,
statement: Union[
Select[_TSelectParam],
SelectOfScalar[_TSelectParam],
Executable[_TSelectParam],
_Executable,
],
*,
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
bind_arguments: Optional[Dict[str, Any]] = None,
_parent_execute_state: Optional[Any] = None,
_add_event: Optional[Any] = None,
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam]]:
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam], Result[Any]]:
results = super().execute(
statement,
params=params,
Expand Down
Loading