class documentation

Base class for elements of a programmatically constructed SQL expression.

Method __bool__ Undocumented
Method __getstate__ Undocumented
Method __invert__ Undocumented
Method __repr__ Undocumented
Method compare Compare this :class:`_expression.ClauseElement` to the given :class:`_expression.ClauseElement`.
Method get_children Return immediate child :class:`.visitors.HasTraverseInternals` elements of this :class:`.visitors.HasTraverseInternals`.
Method params Return a copy with :func:`_expression.bindparam` elements replaced.
Method self_group Apply a 'grouping' to this :class:`_expression.ClauseElement`.
Method unique_params Return a copy with :func:`_expression.bindparam` elements replaced.
Class Variable __visit_name__ Undocumented
Class Variable is_clause_element Undocumented
Class Variable is_dml Undocumented
Class Variable is_selectable Undocumented
Class Variable negation_clause Undocumented
Property description Undocumented
Property entity_namespace Undocumented
Method _clone Create a shallow copy of this ClauseElement.
Method _cloned_set Return the set consisting all cloned ancestors of this ClauseElement.
Method _compile_w_cache Undocumented
Method _execute_on_connection Undocumented
Method _execute_on_scalar an additional hook for subclasses to provide a different implementation for connection.scalar() vs. connection.execute().
Method _negate Undocumented
Method _negate_in_binary a hook to allow the right side of a binary expression to respond to a negation of the binary expression.
Method _replace_params Undocumented
Method _set_propagate_attrs Undocumented
Method _ungroup Return this :class:`_expression.ClauseElement` without any groupings.
Method _with_binary_element_type in the context of binary expression, convert the type of this object to the one given.
Class Variable _cache_key_traversal Undocumented
Class Variable _gen_static_annotations_cache_key Undocumented
Class Variable _is_bind_parameter Undocumented
Class Variable _is_clause_list Undocumented
Class Variable _is_clone_of Undocumented
Class Variable _is_column_element Undocumented
Class Variable _is_from_clause Undocumented
Class Variable _is_from_container Undocumented
Class Variable _is_immutable Undocumented
Class Variable _is_keyed_column_element Undocumented
Class Variable _is_lambda_element Undocumented
Class Variable _is_returns_rows Undocumented
Class Variable _is_select_base Undocumented
Class Variable _is_select_container Undocumented
Class Variable _is_select_statement Undocumented
Class Variable _is_singleton_constant Undocumented
Class Variable _is_star Undocumented
Class Variable _is_table Undocumented
Class Variable _is_text_clause Undocumented
Class Variable _is_textual Undocumented
Instance Variable _propagate_attrs like annotations, however these propagate outwards liberally as SQL constructs are built, and are set up at construction time.
Property _constructor return the 'constructor' for this ClauseElement.
Property _from_objects Undocumented
Property _order_by_label_element Undocumented

Inherited from SupportsWrappingAnnotations:

Class Variable __slots__ Undocumented
Method _annotate return a copy of this ClauseElement with annotations updated by the given dictionary.
Method _deannotate return a copy of this :class:`_expression.ClauseElement` with annotations removed.
Method _with_annotations return a copy of this ClauseElement with annotations replaced by the given dictionary.

Inherited from SupportsAnnotations (via SupportsWrappingAnnotations):

Class Variable proxy_set Undocumented
Method _gen_annotations_cache_key Undocumented
Property _annotations_cache_key Undocumented

Inherited from MemoizedHasCacheKey (via SupportsWrappingAnnotations, SupportsAnnotations):

Method _generate_cache_key return a cache key.

Inherited from HasCacheKey (via SupportsWrappingAnnotations, SupportsAnnotations, MemoizedHasCacheKey):

Class Variable inherit_cache Indicate if this :class:`.HasCacheKey` instance should make use of the cache key generation scheme used by its immediate superclass.
Class Method _generate_cache_attrs generate cache key dispatcher for a new class.
Class Method _generate_cache_key_for_object Undocumented
Method _gen_cache_key return an optional cache key.
Class Variable _generated_cache_key_traversal Undocumented
Class Variable _hierarchy_supports_caching private attribute which may be set to False to prevent the inherit_cache warning from being emitted for a hierarchy of subclasses.
Class Variable _is_has_cache_key Undocumented

Inherited from HasCopyInternals (via SupportsWrappingAnnotations, SupportsAnnotations, MemoizedHasCacheKey, HasCacheKey):

Method _copy_internals Reassign internal elements to be clones of themselves.

Inherited from HasTraverseInternals (via SupportsWrappingAnnotations, SupportsAnnotations, MemoizedHasCacheKey, HasCacheKey, HasCopyInternals, ExternallyTraversible):

Class Variable _traverse_internals Undocumented

Inherited from CompilerElement (via SupportsWrappingAnnotations, SupportsAnnotations, MemoizedHasCacheKey, HasCacheKey, HasCopyInternals, ExternallyTraversible, HasTraverseInternals):

Method __str__ Undocumented
Method compile Compile this SQL expression.
Class Variable stringify_dialect Undocumented
Class Variable supports_execution Undocumented
Method _compiler Return a compiler appropriate for this ClauseElement, given a Dialect.

Inherited from Visitable (via SupportsWrappingAnnotations, SupportsAnnotations, MemoizedHasCacheKey, HasCacheKey, HasCopyInternals, ExternallyTraversible, HasTraverseInternals, CompilerElement):

Method __class_getitem__ Undocumented
Method __init_subclass__ Undocumented
Class Method _generate_compiler_dispatch Undocumented
Method _compiler_dispatch Undocumented
Class Variable _original_compiler_dispatch Undocumented
def __bool__(self): (source)

Undocumented

def __invert__(self): (source)

Undocumented

def compare(self, other: ClauseElement, **kw: Any) -> bool: (source)

Compare this :class:`_expression.ClauseElement` to the given :class:`_expression.ClauseElement`. Subclasses should override the default behavior, which is a straight identity comparison. \**kw are arguments consumed by subclass ``compare()`` methods and may be used to modify the criteria for comparison (see :class:`_expression.ColumnElement`).

def get_children(self, *, omit_attrs: typing_Tuple[str, ...] = ..., **kw: Any) -> Iterable[ClauseElement]: (source)

Return immediate child :class:`.visitors.HasTraverseInternals` elements of this :class:`.visitors.HasTraverseInternals`. This is used for visit traversal. \**kw may contain flags that change the collection that is returned, for example to return a subset of items in order to cut down on larger traversals, or to return child items from a different context (such as schema-level collections instead of clause-level).

def params(self, __optionaldict: Optional[Mapping[str, Any]] = None, **kwargs: Any) -> Self: (source)

Return a copy with :func:`_expression.bindparam` elements replaced. Returns a copy of this ClauseElement with :func:`_expression.bindparam` elements replaced with values taken from the given dictionary:: >>> clause = column('x') + bindparam('foo') >>> print(clause.compile().params) {'foo':None} >>> print(clause.params({'foo':7}).compile().params) {'foo':7}

def self_group(self, against: Optional[OperatorType] = None) -> ClauseElement: (source)

Apply a 'grouping' to this :class:`_expression.ClauseElement`. This method is overridden by subclasses to return a "grouping" construct, i.e. parenthesis. In particular it's used by "binary" expressions to provide a grouping around themselves when placed into a larger expression, as well as by :func:`_expression.select` constructs when placed into the FROM clause of another :func:`_expression.select`. (Note that subqueries should be normally created using the :meth:`_expression.Select.alias` method, as many platforms require nested SELECT statements to be named). As expressions are composed together, the application of :meth:`self_group` is automatic - end-user code should never need to use this method directly. Note that SQLAlchemy's clause constructs take operator precedence into account - so parenthesis might not be needed, for example, in an expression like ``x OR (y AND z)`` - AND takes precedence over OR. The base :meth:`self_group` method of :class:`_expression.ClauseElement` just returns self.

def unique_params(self, __optionaldict: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Self: (source)

Return a copy with :func:`_expression.bindparam` elements replaced. Same functionality as :meth:`_expression.ClauseElement.params`, except adds `unique=True` to affected bind parameters so that multiple statements can be used.

__visit_name__: str = (source)
overridden in sqlalchemy.dialects.mysql.dml.OnDuplicateClause, sqlalchemy.dialects.postgresql.CreateDomainType, sqlalchemy.dialects.postgresql.CreateEnumType, sqlalchemy.dialects.postgresql.dml.OnConflictDoNothing, sqlalchemy.dialects.postgresql.dml.OnConflictDoUpdate, sqlalchemy.dialects.postgresql.DropDomainType, sqlalchemy.dialects.postgresql.DropEnumType, sqlalchemy.dialects.sqlite.dml.OnConflictDoNothing, sqlalchemy.dialects.sqlite.dml.OnConflictDoUpdate, sqlalchemy.orm.context.FromStatement, sqlalchemy.sql.ddl.AddConstraint, sqlalchemy.sql.ddl.CreateColumn, sqlalchemy.sql.ddl.CreateIndex, sqlalchemy.sql.ddl.CreateSchema, sqlalchemy.sql.ddl.CreateSequence, sqlalchemy.sql.ddl.CreateTable, sqlalchemy.sql.ddl.DDL, sqlalchemy.sql.ddl.DropColumnComment, sqlalchemy.sql.ddl.DropConstraint, sqlalchemy.sql.ddl.DropConstraintComment, sqlalchemy.sql.ddl.DropIndex, sqlalchemy.sql.ddl.DropSchema, sqlalchemy.sql.ddl.DropSequence, sqlalchemy.sql.ddl.DropTable, sqlalchemy.sql.ddl.DropTableComment, sqlalchemy.sql.ddl.SetColumnComment, sqlalchemy.sql.ddl.SetConstraintComment, sqlalchemy.sql.ddl.SetTableComment, sqlalchemy.sql.dml.UpdateBase, sqlalchemy.sql.dml.UpdateBase, sqlalchemy.sql.dml.UpdateBase, sqlalchemy.sql.elements.ClauseList, sqlalchemy.sql.elements.ColumnElement, sqlalchemy.sql.elements.GroupedElement, sqlalchemy.sql.elements.TextClause, sqlalchemy.sql.elements.TypeClause, sqlalchemy.sql.lambdas.LambdaElement, sqlalchemy.sql.lambdas.NullLambdaStatement, sqlalchemy.sql.selectable.CompoundSelect, sqlalchemy.sql.selectable.CompoundSelect, sqlalchemy.sql.selectable.Select, sqlalchemy.sql.selectable.Select, sqlalchemy.sql.selectable.Selectable, sqlalchemy.sql.selectable.SelectStatementGrouping, sqlalchemy.sql.selectable.TextualSelect, sqlalchemy.sql.selectable.TextualSelect, sqlalchemy.sql.ddl._DropView, sqlalchemy.sql.elements._IdentifiedClause

Undocumented

is_clause_element: bool = (source)

Undocumented

is_selectable: bool = (source)

Undocumented

negation_clause: ColumnElement[bool] = (source)

Undocumented

@util.ro_memoized_property
description: Optional[str] = (source)
def _clone(self, **kw: Any) -> Self: (source)

Create a shallow copy of this ClauseElement. This method may be used by a generative API. Its also used as part of the "deep" copy afforded by a traversal that combines the _copy_internals() method.

@HasMemoized.memoized_attribute
def _cloned_set(self): (source)

Return the set consisting all cloned ancestors of this ClauseElement. Includes this ClauseElement. This accessor tends to be used for FromClause objects to identify 'equivalent' FROM clauses, regardless of transformative operations.

def _compile_w_cache(self, dialect: Dialect, *, compiled_cache: Optional[CompiledCacheType], column_keys: List[str], for_executemany: bool = False, schema_translate_map: Optional[SchemaTranslateMapType] = None, **kw: Any) -> typing_Tuple[Compiled, Optional[Sequence[BindParameter[Any]]], CacheStats]: (source)

Undocumented

def _execute_on_scalar(self, connection: Connection, distilled_params: _CoreMultiExecuteParams, execution_options: CoreExecuteOptionsParameter) -> Any: (source)

an additional hook for subclasses to provide a different implementation for connection.scalar() vs. connection.execute(). .. versionadded:: 2.0

def _negate(self) -> ClauseElement: (source)

Undocumented

def _negate_in_binary(self, negated_op, original_op): (source)

a hook to allow the right side of a binary expression to respond to a negation of the binary expression. Used for the special case of expanding bind parameter with IN.

def _replace_params(self, unique: bool, optionaldict: Optional[Mapping[str, Any]], kwargs: Dict[str, Any]) -> Self: (source)

Undocumented

def _set_propagate_attrs(self, values: Mapping[str, Any]) -> Self: (source)

Undocumented

def _with_binary_element_type(self, type_): (source)

in the context of binary expression, convert the type of this object to the one given. applies only to :class:`_expression.ColumnElement` classes.

_gen_static_annotations_cache_key: bool = (source)

Undocumented

_is_bind_parameter: bool = (source)

Undocumented

_is_clause_list: bool = (source)

Undocumented

_is_column_element: bool = (source)

Undocumented

_is_from_clause: bool = (source)

Undocumented

_is_keyed_column_element: bool = (source)

Undocumented

_is_returns_rows: bool = (source)

Undocumented

_is_select_base: bool = (source)

Undocumented

_is_select_statement: bool = (source)

Undocumented

_is_singleton_constant: bool = (source)

Undocumented

_is_table: bool = (source)

Undocumented

_is_text_clause: bool = (source)

Undocumented

@util.memoized_property
_propagate_attrs = (source)

like annotations, however these propagate outwards liberally as SQL constructs are built, and are set up at construction time.

@property
_constructor = (source)

return the 'constructor' for this ClauseElement. This is for the purposes for creating a new object of this type. Usually, its just the element's __class__. However, the "Annotated" version of the object overrides to return the class of its proxied element.