diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2023-05-10 20:15:15 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2023-05-10 20:15:15 +0000 |
| commit | 4f52073370ae2a563fdc3fe05d87ee1ea4ee901d (patch) | |
| tree | 1f1b87086516abe7dbc5f4f5a6734aa929f0e00a /lib/sqlalchemy | |
| parent | bce61160a9aec321ea0af4a59d4b83ff93a0429f (diff) | |
| parent | 189039b9d38343b482f1b077bbcf6f6ae99cbacd (diff) | |
| download | sqlalchemy-4f52073370ae2a563fdc3fe05d87ee1ea4ee901d.tar.gz | |
Merge "add full parameter types for ORM with_for_update" into main
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/ext/asyncio/scoping.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/asyncio/session.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/scoping.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/session.py | 7 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 5 |
5 files changed, 17 insertions, 13 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/scoping.py b/lib/sqlalchemy/ext/asyncio/scoping.py index 52eeb0828..49d8b3af9 100644 --- a/lib/sqlalchemy/ext/asyncio/scoping.py +++ b/lib/sqlalchemy/ext/asyncio/scoping.py @@ -55,7 +55,7 @@ if TYPE_CHECKING: from ...orm.session import _SessionBind from ...sql.base import Executable from ...sql.elements import ClauseElement - from ...sql.selectable import ForUpdateArg + from ...sql.selectable import ForUpdateParameter from ...sql.selectable import TypedReturnsRows _T = TypeVar("_T", bound=Any) @@ -217,7 +217,7 @@ class async_scoped_session(Generic[_AS]): *, options: Optional[Sequence[ORMOption]] = None, populate_existing: bool = False, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, identity_token: Optional[Any] = None, execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, ) -> Optional[_O]: @@ -934,7 +934,7 @@ class async_scoped_session(Generic[_AS]): self, instance: object, attribute_names: Optional[Iterable[str]] = None, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, ) -> None: r"""Expire and refresh the attributes on the given instance. diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index 00fee9716..615003302 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -62,7 +62,7 @@ if TYPE_CHECKING: from ...sql._typing import _InfoType from ...sql.base import Executable from ...sql.elements import ClauseElement - from ...sql.selectable import ForUpdateArg + from ...sql.selectable import ForUpdateParameter from ...sql.selectable import TypedReturnsRows _AsyncSessionBind = Union["AsyncEngine", "AsyncConnection"] @@ -301,7 +301,7 @@ class AsyncSession(ReversibleProxy[Session]): self, instance: object, attribute_names: Optional[Iterable[str]] = None, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, ) -> None: """Expire and refresh the attributes on the given instance. @@ -566,7 +566,7 @@ class AsyncSession(ReversibleProxy[Session]): *, options: Optional[Sequence[ORMOption]] = None, populate_existing: bool = False, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, identity_token: Optional[Any] = None, execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, ) -> Optional[_O]: diff --git a/lib/sqlalchemy/orm/scoping.py b/lib/sqlalchemy/orm/scoping.py index 19217ec32..83ce6e44e 100644 --- a/lib/sqlalchemy/orm/scoping.py +++ b/lib/sqlalchemy/orm/scoping.py @@ -70,7 +70,7 @@ if TYPE_CHECKING: from ..sql.base import Executable from ..sql.elements import ClauseElement from ..sql.roles import TypedColumnsClauseRole - from ..sql.selectable import ForUpdateArg + from ..sql.selectable import ForUpdateParameter from ..sql.selectable import TypedReturnsRows _T = TypeVar("_T", bound=Any) @@ -889,7 +889,7 @@ class scoped_session(Generic[_S]): *, options: Optional[Sequence[ORMOption]] = None, populate_existing: bool = False, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, identity_token: Optional[Any] = None, execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, bind_arguments: Optional[_BindArguments] = None, @@ -1592,7 +1592,7 @@ class scoped_session(Generic[_S]): self, instance: object, attribute_names: Optional[Iterable[str]] = None, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, ) -> None: r"""Expire and refresh attributes on the given instance. diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 792b59e81..0ce53bcab 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -126,6 +126,7 @@ if typing.TYPE_CHECKING: from ..sql.base import ExecutableOption from ..sql.elements import ClauseElement from ..sql.roles import TypedColumnsClauseRole + from ..sql.selectable import ForUpdateParameter from ..sql.selectable import TypedReturnsRows _T = TypeVar("_T", bound=Any) @@ -2911,7 +2912,7 @@ class Session(_SessionClassMethods, EventTarget): self, instance: object, attribute_names: Optional[Iterable[str]] = None, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, ) -> None: """Expire and refresh attributes on the given instance. @@ -3432,7 +3433,7 @@ class Session(_SessionClassMethods, EventTarget): *, options: Optional[Sequence[ORMOption]] = None, populate_existing: bool = False, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, identity_token: Optional[Any] = None, execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, bind_arguments: Optional[_BindArguments] = None, @@ -3559,7 +3560,7 @@ class Session(_SessionClassMethods, EventTarget): *, options: Optional[Sequence[ExecutableOption]] = None, populate_existing: bool = False, - with_for_update: Optional[ForUpdateArg] = None, + with_for_update: ForUpdateParameter = None, identity_token: Optional[Any] = None, execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, bind_arguments: Optional[_BindArguments] = None, diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 8a371951e..19d464180 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -3067,6 +3067,9 @@ class TableClause(roles.DMLTableRole, Immutable, NamedFromClause): return [self] +ForUpdateParameter = Union["ForUpdateArg", None, bool, Dict[str, Any]] + + class ForUpdateArg(ClauseElement): _traverse_internals: _TraverseInternalsType = [ ("of", InternalTraversal.dp_clauseelement_list), @@ -3082,7 +3085,7 @@ class ForUpdateArg(ClauseElement): @classmethod def _from_argument( - cls, with_for_update: Union[ForUpdateArg, None, bool, Dict[str, Any]] + cls, with_for_update: ForUpdateParameter ) -> Optional[ForUpdateArg]: if isinstance(with_for_update, ForUpdateArg): return with_for_update |
