diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2023-01-30 17:20:39 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2023-01-30 17:20:39 +0000 |
| commit | 3d124c9a917acf31e73b383a990647f2d495df20 (patch) | |
| tree | f4739605d28319a331ab2522f228a552d41d2d56 /lib/sqlalchemy/sql | |
| parent | 956f152a29632afacacc4ea11dce1a54a7afb3ea (diff) | |
| parent | cae662a6383d3ae8f3673c70c3118ea3a1a1606e (diff) | |
| download | sqlalchemy-3d124c9a917acf31e73b383a990647f2d495df20.tar.gz | |
Merge "allow single tables and entities for "of"" into main
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/_typing.py | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 36 |
2 files changed, 18 insertions, 19 deletions
diff --git a/lib/sqlalchemy/sql/_typing.py b/lib/sqlalchemy/sql/_typing.py index da3a9ad4e..5c1a501e4 100644 --- a/lib/sqlalchemy/sql/_typing.py +++ b/lib/sqlalchemy/sql/_typing.py @@ -186,7 +186,6 @@ overall which brings in the TextClause object also. """ - _ColumnExpressionOrLiteralArgument = Union[Any, _ColumnExpressionArgument[_T]] _ColumnExpressionOrStrLabelArgument = Union[str, _ColumnExpressionArgument[_T]] diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 8fb9ea0cd..78fc7b1b7 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -163,6 +163,16 @@ class _JoinTargetProtocol(Protocol): _JoinTargetElement = Union["FromClause", _JoinTargetProtocol] _OnClauseElement = Union["ColumnElement[bool]", _JoinTargetProtocol] +_ForUpdateOfArgument = Union[ + # single column, Table, ORM Entity + Union[ + "_ColumnExpressionArgument[Any]", + "_FromClauseArgument", + ], + # or sequence of single column elements + Sequence["_ColumnExpressionArgument[Any]"], +] + _SetupJoinsElement = Tuple[ _JoinTargetElement, @@ -3151,12 +3161,7 @@ class ForUpdateArg(ClauseElement): *, nowait: bool = False, read: bool = False, - of: Optional[ - Union[ - _ColumnExpressionArgument[Any], - Sequence[_ColumnExpressionArgument[Any]], - ] - ] = None, + of: Optional[_ForUpdateOfArgument] = None, skip_locked: bool = False, key_share: bool = False, ): @@ -3822,12 +3827,7 @@ class GenerativeSelect(SelectBase, Generative): *, nowait: bool = False, read: bool = False, - of: Optional[ - Union[ - _ColumnExpressionArgument[Any], - Sequence[_ColumnExpressionArgument[Any]], - ] - ] = None, + of: Optional[_ForUpdateOfArgument] = None, skip_locked: bool = False, key_share: bool = False, ) -> SelfGenerativeSelect: @@ -3860,12 +3860,12 @@ class GenerativeSelect(SelectBase, Generative): ``FOR SHARE`` on PostgreSQL. On PostgreSQL, when combined with ``nowait``, will render ``FOR SHARE NOWAIT``. - :param of: SQL expression or list of SQL expression elements - (typically :class:`_schema.Column` - objects or a compatible expression) which - will render into a ``FOR UPDATE OF`` clause; supported by PostgreSQL - and Oracle. May render as a table or as a column depending on - backend. + :param of: SQL expression or list of SQL expression elements, + (typically :class:`_schema.Column` objects or a compatible expression, + for some backends may also be a table expression) which will render + into a ``FOR UPDATE OF`` clause; supported by PostgreSQL Oracle, some + MySQL versions and possibly others. May render as a table or as a + column depending on backend. :param skip_locked: boolean, will render ``FOR UPDATE SKIP LOCKED`` on Oracle and PostgreSQL dialects or ``FOR SHARE SKIP LOCKED`` if |
