Skip to content

Commit 4ec8aac

Browse files
committed
Fix overload implementation
1 parent 4d13aa3 commit 4ec8aac

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

sqlmodel/ext/asyncio/session.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
)
1313

1414
from sqlalchemy import util
15+
from sqlalchemy.engine.cursor import CursorResult
1516
from sqlalchemy.engine.interfaces import _CoreAnyExecuteParams
1617
from sqlalchemy.engine.result import Result, ScalarResult, TupleResult
1718
from sqlalchemy.ext.asyncio import AsyncSession as _AsyncSession
1819
from sqlalchemy.ext.asyncio.result import _ensure_sync_result
1920
from sqlalchemy.ext.asyncio.session import _EXECUTE_OPTIONS
2021
from sqlalchemy.orm._typing import OrmExecuteOptionsParameter
2122
from sqlalchemy.sql.base import Executable as _Executable
23+
from sqlalchemy.sql.dml import UpdateBase
2224
from sqlalchemy.util.concurrency import greenlet_spawn
2325
from typing_extensions import deprecated
2426

@@ -60,30 +62,30 @@ async def exec(
6062
@overload
6163
async def exec(
6264
self,
63-
statement: _Executable,
65+
statement: UpdateBase,
6466
*,
6567
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
6668
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
6769
bind_arguments: Optional[Dict[str, Any]] = None,
6870
_parent_execute_state: Optional[Any] = None,
6971
_add_event: Optional[Any] = None,
70-
) -> Result[Any]: ...
72+
) -> CursorResult[Any]: ...
7173

7274
async def exec(
7375
self,
7476
statement: Union[
7577
Select[_TSelectParam],
7678
SelectOfScalar[_TSelectParam],
7779
Executable[_TSelectParam],
78-
_Executable,
80+
UpdateBase,
7981
],
8082
*,
8183
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
8284
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
8385
bind_arguments: Optional[Dict[str, Any]] = None,
8486
_parent_execute_state: Optional[Any] = None,
8587
_add_event: Optional[Any] = None,
86-
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam], Result[Any]]:
88+
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam], CursorResult[Any]]:
8789
if execution_options:
8890
execution_options = util.immutabledict(execution_options).union(
8991
_EXECUTE_OPTIONS

sqlmodel/orm/session.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
)
1111

1212
from sqlalchemy import util
13+
from sqlalchemy.engine.cursor import CursorResult
1314
from sqlalchemy.engine.interfaces import _CoreAnyExecuteParams
1415
from sqlalchemy.engine.result import Result, ScalarResult, TupleResult
1516
from sqlalchemy.orm import Query as _Query
1617
from sqlalchemy.orm import Session as _Session
1718
from sqlalchemy.orm._typing import OrmExecuteOptionsParameter
1819
from sqlalchemy.sql._typing import _ColumnsClauseArgument
1920
from sqlalchemy.sql.base import Executable as _Executable
21+
from sqlalchemy.sql.dml import UpdateBase
2022
from sqlmodel.sql.base import Executable
2123
from sqlmodel.sql.expression import Select, SelectOfScalar
2224
from typing_extensions import deprecated
@@ -52,30 +54,30 @@ def exec(
5254
@overload
5355
def exec(
5456
self,
55-
statement: _Executable,
57+
statement: UpdateBase,
5658
*,
5759
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
5860
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
5961
bind_arguments: Optional[Dict[str, Any]] = None,
6062
_parent_execute_state: Optional[Any] = None,
6163
_add_event: Optional[Any] = None,
62-
) -> Result[Any]: ...
64+
) -> CursorResult[Any]: ...
6365

6466
def exec(
6567
self,
6668
statement: Union[
6769
Select[_TSelectParam],
6870
SelectOfScalar[_TSelectParam],
6971
Executable[_TSelectParam],
70-
_Executable,
72+
UpdateBase,
7173
],
7274
*,
7375
params: Optional[Union[Mapping[str, Any], Sequence[Mapping[str, Any]]]] = None,
7476
execution_options: Mapping[str, Any] = util.EMPTY_DICT,
7577
bind_arguments: Optional[Dict[str, Any]] = None,
7678
_parent_execute_state: Optional[Any] = None,
7779
_add_event: Optional[Any] = None,
78-
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam], Result[Any]]:
80+
) -> Union[TupleResult[_TSelectParam], ScalarResult[_TSelectParam], CursorResult[Any]]:
7981
results = super().execute(
8082
statement,
8183
params=params,

0 commit comments

Comments
 (0)