diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-05-10 11:08:07 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-05-10 15:24:11 -0400 |
commit | 189039b9d38343b482f1b077bbcf6f6ae99cbacd (patch) | |
tree | a4f853e10dd00ae2de18e8a32139b925dfcbd2c5 /lib/sqlalchemy/sql/selectable.py | |
parent | 987285fb4b13c39bcc6b8922e618d9e830577dda (diff) | |
download | sqlalchemy-189039b9d38343b482f1b077bbcf6f6ae99cbacd.tar.gz |
add full parameter types for ORM with_for_update
Fixed typing for the :paramref:`_orm.Session.get.with_for_update` parameter
of :meth:`_orm.Session.get` and :meth:`_orm.Session.refresh` (as well as
corresponding methods on :class:`_asyncio.AsyncSession`) to accept boolean
``True`` and all other argument forms accepted by the parameter at runtime.
Fixes: #9762
Change-Id: Ied4d37a269906b3d9be5ab7d31a2fa863360cced
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
-rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 5 |
1 files changed, 4 insertions, 1 deletions
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 |