diff options
author | Federico Caselli <cfederico87@gmail.com> | 2022-10-17 22:02:13 +0200 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-02 21:38:31 -0400 |
commit | d10b62f54e6b9dd0613c0412b924c1b346ec1611 (patch) | |
tree | 07d246255d0372c5a7839e1aec354edacf687fdf /lib/sqlalchemy/sql/base.py | |
parent | 66e591cf8a5de6d5dabdecf2bb279dec90962e15 (diff) | |
download | sqlalchemy-d10b62f54e6b9dd0613c0412b924c1b346ec1611.tar.gz |
Improve typings of execution options
Fixes: #8605
Change-Id: I4aec83b9f321462427c3f4ac941c3b272255c088
Diffstat (limited to 'lib/sqlalchemy/sql/base.py')
-rw-r--r-- | lib/sqlalchemy/sql/base.py | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 2a8479c6d..a8901c144 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -64,6 +64,8 @@ if TYPE_CHECKING: from . import coercions from . import elements from . import type_api + from ._orm_types import DMLStrategyArgument + from ._orm_types import SynchronizeSessionArgument from .elements import BindParameter from .elements import ClauseList from .elements import ColumnClause # noqa @@ -77,15 +79,16 @@ if TYPE_CHECKING: from .selectable import FromClause from ..engine import Connection from ..engine import CursorResult - from ..engine.base import _CompiledCacheType from ..engine.interfaces import _CoreMultiExecuteParams from ..engine.interfaces import _ExecuteOptions - from ..engine.interfaces import _ExecuteOptionsParameter from ..engine.interfaces import _ImmutableExecuteOptions - from ..engine.interfaces import _SchemaTranslateMapType from ..engine.interfaces import CacheStats from ..engine.interfaces import Compiled + from ..engine.interfaces import CompiledCacheType + from ..engine.interfaces import CoreExecuteOptionsParameter from ..engine.interfaces import Dialect + from ..engine.interfaces import IsolationLevel + from ..engine.interfaces import SchemaTranslateMapType from ..event import dispatcher if not TYPE_CHECKING: @@ -1009,10 +1012,10 @@ class Executable(roles.StatementRole): self, dialect: Dialect, *, - compiled_cache: Optional[_CompiledCacheType], + compiled_cache: Optional[CompiledCacheType], column_keys: List[str], for_executemany: bool = False, - schema_translate_map: Optional[_SchemaTranslateMapType] = None, + schema_translate_map: Optional[SchemaTranslateMapType] = None, **kw: Any, ) -> Tuple[ Compiled, Optional[Sequence[BindParameter[Any]]], CacheStats @@ -1023,7 +1026,7 @@ class Executable(roles.StatementRole): self, connection: Connection, distilled_params: _CoreMultiExecuteParams, - execution_options: _ExecuteOptionsParameter, + execution_options: CoreExecuteOptionsParameter, ) -> CursorResult[Any]: ... @@ -1031,7 +1034,7 @@ class Executable(roles.StatementRole): self, connection: Connection, distilled_params: _CoreMultiExecuteParams, - execution_options: _ExecuteOptionsParameter, + execution_options: CoreExecuteOptionsParameter, ) -> Any: ... @@ -1123,6 +1126,33 @@ class Executable(roles.StatementRole): self._with_context_options += ((callable_, cache_args),) return self + @overload + def execution_options( + self: SelfExecutable, + *, + compiled_cache: Optional[CompiledCacheType] = ..., + logging_token: str = ..., + isolation_level: IsolationLevel = ..., + no_parameters: bool = False, + stream_results: bool = False, + max_row_buffer: int = ..., + yield_per: int = ..., + insertmanyvalues_page_size: int = ..., + schema_translate_map: Optional[SchemaTranslateMapType] = ..., + populate_existing: bool = False, + autoflush: bool = False, + synchronize_session: SynchronizeSessionArgument = ..., + dml_strategy: DMLStrategyArgument = ..., + is_delete_using: bool = ..., + is_update_from: bool = ..., + **opt: Any, + ) -> SelfExecutable: + ... + + @overload + def execution_options(self: SelfExecutable, **opt: Any) -> SelfExecutable: + ... + @_generative def execution_options(self: SelfExecutable, **kw: Any) -> SelfExecutable: """Set non-SQL options for the statement which take effect during |