From 5ebb402c686abf1090e5b83e3489dfca4908efdf Mon Sep 17 00:00:00 2001 From: Yossi <54272821+Apakottur@users.noreply.github.com> Date: Mon, 1 Dec 2025 16:38:56 +0000 Subject: [PATCH] Add coercion --- lib/sqlalchemy/sql/_selectable_constructors.py | 4 ++-- lib/sqlalchemy/sql/selectable.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/sqlalchemy/sql/_selectable_constructors.py b/lib/sqlalchemy/sql/_selectable_constructors.py index 06f0423b8d..540f749798 100644 --- a/lib/sqlalchemy/sql/_selectable_constructors.py +++ b/lib/sqlalchemy/sql/_selectable_constructors.py @@ -34,7 +34,7 @@ from ..util.typing import TupleAny from ..util.typing import Unpack if TYPE_CHECKING: - from ._typing import _DMLColumnArgument + from ._typing import _DMLOnlyColumnArgument from ._typing import _FromClauseArgument from ._typing import _OnClauseArgument from ._typing import _SelectStatementForCompoundArgument @@ -685,7 +685,7 @@ def union_all( def values( - *columns: _DMLColumnArgument[Any], + *columns: _DMLOnlyColumnArgument[Any], name: Optional[str] = None, literal_binds: bool = False, ) -> Values: diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index da5752692a..e81ed2b66e 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -117,7 +117,7 @@ and_ = BooleanClauseList.and_ if TYPE_CHECKING: from ._typing import _ColumnExpressionArgument from ._typing import _ColumnExpressionOrStrLabelArgument - from ._typing import _DMLColumnArgument + from ._typing import _DMLOnlyColumnArgument from ._typing import _FromClauseArgument from ._typing import _JoinTargetArgument from ._typing import _LimitOffsetType @@ -3356,6 +3356,7 @@ class Values(roles.InElementRole, HasCTE, Generative, LateralFromClause): __visit_name__ = "values" _data: Tuple[Sequence[Tuple[Any, ...]], ...] = () + _column_args: Tuple[ColumnClause[Any], ...] _unnamed: bool _traverse_internals: _TraverseInternalsType = [ @@ -3369,12 +3370,15 @@ class Values(roles.InElementRole, HasCTE, Generative, LateralFromClause): def __init__( self, - *columns: _DMLColumnArgument[Any], + *columns: _DMLOnlyColumnArgument[Any], name: Optional[str] = None, literal_binds: bool = False, ): super().__init__() - self._column_args = columns + self._column_args = tuple( + coercions.expect(roles.DMLColumnRole, col) # type: ignore[misc] + for col in columns + ) if name is None: self._unnamed = True @@ -7119,6 +7123,7 @@ class Exists(UnaryExpression[bool]): self, fn: Callable[[Select[Unpack[TupleAny]]], Select[Unpack[TupleAny]]], ) -> ScalarSelect[Any]: + assert isinstance(self.element, ScalarSelect) element = self.element.element if not isinstance(element, Select): -- 2.47.3