diff options
author | Federico Caselli <cfederico87@gmail.com> | 2023-04-24 11:24:32 +0200 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2023-04-27 23:32:25 +0200 |
commit | 7bf624eb616e88f33bcf3f8b11b9c5b7dd2ba890 (patch) | |
tree | 09ae0e5b3f743cef67ea00b90695f7f6b5ce52d7 | |
parent | 0596adcc27e4e14c4692a58cd32d39df6f48b09a (diff) | |
download | sqlalchemy-7bf624eb616e88f33bcf3f8b11b9c5b7dd2ba890.tar.gz |
Add public alias of type _ColumnExpressionArgument
Added type ``ColumnExpressionArgument`` as a public alias of an internal
type. This type is useful since it's what' accepted by the sqlalchemy in
many api calls, such as :meth:`_sql.Select.where`, :meth:`_sql.and` and
many other.
Fixes: #9656
Change-Id: I79a38a0c1417d0ed1b6efff00497dba5e2be4f79
-rw-r--r-- | doc/build/changelog/unreleased_20/9656.rst | 8 | ||||
-rw-r--r-- | doc/build/core/internals.rst | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/__init__.py | 1 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/__init__.py | 1 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/_typing.py | 8 |
5 files changed, 18 insertions, 3 deletions
diff --git a/doc/build/changelog/unreleased_20/9656.rst b/doc/build/changelog/unreleased_20/9656.rst new file mode 100644 index 000000000..16c170aa8 --- /dev/null +++ b/doc/build/changelog/unreleased_20/9656.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: typing, sql + :tickets: 9656 + + Added type ``ColumnExpressionArgument`` as a public alias of an internal + type. This type is useful since it's what' accepted by the sqlalchemy in + many api calls, such as :meth:`_sql.Select.where`, :meth:`_sql.and` and + many other. diff --git a/doc/build/core/internals.rst b/doc/build/core/internals.rst index e3769b342..26aa9831d 100644 --- a/doc/build/core/internals.rst +++ b/doc/build/core/internals.rst @@ -69,3 +69,6 @@ Some key internal constructs are listed here. .. autoclass:: sqlalchemy.engine.AdaptedConnection :members: + +.. autoattribute:: sqlalchemy.sql.ColumnExpressionArgument + :members: diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py index e9f94f1d9..ed37598ed 100644 --- a/lib/sqlalchemy/__init__.py +++ b/lib/sqlalchemy/__init__.py @@ -79,6 +79,7 @@ from .schema import PrimaryKeyConstraint as PrimaryKeyConstraint from .schema import Sequence as Sequence from .schema import Table as Table from .schema import UniqueConstraint as UniqueConstraint +from .sql import ColumnExpressionArgument as ColumnExpressionArgument from .sql import SelectLabelStyle as SelectLabelStyle from .sql.expression import Alias as Alias from .sql.expression import alias as alias diff --git a/lib/sqlalchemy/sql/__init__.py b/lib/sqlalchemy/sql/__init__.py index e5bbe65da..96cffed7d 100644 --- a/lib/sqlalchemy/sql/__init__.py +++ b/lib/sqlalchemy/sql/__init__.py @@ -7,6 +7,7 @@ from typing import Any from typing import TYPE_CHECKING +from ._typing import ColumnExpressionArgument as ColumnExpressionArgument from .base import Executable as Executable from .compiler import COLLECT_CARTESIAN_PRODUCTS as COLLECT_CARTESIAN_PRODUCTS from .compiler import FROM_LINTING as FROM_LINTING diff --git a/lib/sqlalchemy/sql/_typing.py b/lib/sqlalchemy/sql/_typing.py index 596493b7c..9e83c3f42 100644 --- a/lib/sqlalchemy/sql/_typing.py +++ b/lib/sqlalchemy/sql/_typing.py @@ -26,6 +26,7 @@ from .. import util from ..inspection import Inspectable from ..util.typing import Literal from ..util.typing import Protocol +from ..util.typing import TypeAlias if TYPE_CHECKING: from datetime import date @@ -175,7 +176,10 @@ _ColumnExpressionArgument = Union[ Callable[[], "ColumnElement[_T]"], "LambdaElement", ] -"""narrower "column expression" argument. +"See docs in public alias ColumnExpressionArgument." + +ColumnExpressionArgument: TypeAlias = _ColumnExpressionArgument[_T] +"""Narrower "column expression" argument. This type is used for all the other "column" kinds of expressions that typically represent a single SQL column expression, not a set of columns the @@ -184,10 +188,8 @@ way a table or ORM entity does. This includes ColumnElement, or ORM-mapped attributes that will have a `__clause_element__()` method, it also has the ExpressionElementRole overall which brings in the TextClause object also. - """ - _ColumnExpressionOrLiteralArgument = Union[Any, _ColumnExpressionArgument[_T]] _ColumnExpressionOrStrLabelArgument = Union[str, _ColumnExpressionArgument[_T]] |