diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2022-11-21 21:23:12 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-11-21 21:23:12 +0000 |
| commit | 5ff55f70780788938ab81b7f24a5ce75c3cd45b9 (patch) | |
| tree | cf04f62da16f6af8ee9d543376ff03a667e9848d /lib/sqlalchemy/sql | |
| parent | ece524c0059d0814e45f4bba63abebd7e9af4b8b (diff) | |
| parent | caa9293e2e0d0b186a24962ad72b954271934913 (diff) | |
| download | sqlalchemy-5ff55f70780788938ab81b7f24a5ce75c3cd45b9.tar.gz | |
Merge "add common base class for all SQL col expression objects" into main
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/__init__.py | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/elements.py | 22 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 1 |
3 files changed, 23 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/__init__.py b/lib/sqlalchemy/sql/__init__.py index 5702d6c25..8dae9c3f5 100644 --- a/lib/sqlalchemy/sql/__init__.py +++ b/lib/sqlalchemy/sql/__init__.py @@ -82,6 +82,7 @@ from .expression import Select as Select from .expression import select as select from .expression import Selectable as Selectable from .expression import SelectLabelStyle as SelectLabelStyle +from .expression import SQLColumnExpression as SQLColumnExpression from .expression import StatementLambdaElement as StatementLambdaElement from .expression import Subquery as Subquery from .expression import table as table diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index d9a1a9358..914d2b326 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -1115,6 +1115,26 @@ class SQLCoreOperations(Generic[_T], ColumnOperators, TypingOnly): ... +class SQLColumnExpression( + SQLCoreOperations[_T], roles.ExpressionElementRole[_T], TypingOnly +): + """A type that may be used to indicate any SQL column element or object + that acts in place of one. + + :class:`.SQLColumnExpression` is a base of + :class:`.ColumnElement`, as well as within the bases of ORM elements + such as :class:`.InstrumentedAttribute`, and may be used in :pep:`484` + typing to indicate arguments or return values that should behave + as column expressions. + + .. versionadded:: 2.0.0b4 + + + """ + + __slots__ = () + + _SQO = SQLCoreOperations SelfColumnElement = TypeVar("SelfColumnElement", bound="ColumnElement[Any]") @@ -1131,7 +1151,7 @@ class ColumnElement( roles.DMLColumnRole, roles.DDLConstraintColumnRole, roles.DDLExpressionRole, - SQLCoreOperations[_T], + SQLColumnExpression[_T], DQLDMLClauseElement, ): """Represent a column-oriented SQL expression suitable for usage in the diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index d08bbf4eb..2498bfb37 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -95,6 +95,7 @@ from .elements import quoted_name as quoted_name from .elements import ReleaseSavepointClause as ReleaseSavepointClause from .elements import RollbackToSavepointClause as RollbackToSavepointClause from .elements import SavepointClause as SavepointClause +from .elements import SQLColumnExpression as SQLColumnExpression from .elements import TextClause as TextClause from .elements import True_ as True_ from .elements import Tuple as Tuple |
