class documentation

class ClauseElement(roles.SQLRole, SupportsWrappingAnnotations, MemoizedHasCacheKey, HasCopyInternals, Traversible):

Known subclasses: sqlalchemy.sql.dml.UpdateBase, sqlalchemy.sql.elements.ClauseList, sqlalchemy.sql.elements.TextClause, sqlalchemy.sql.expression.ColumnElement, sqlalchemy.sql.expression.LambdaElement, sqlalchemy.sql.selectable.ReturnsRows, sqlalchemy.databases.oracle._OuterJoinColumn, sqlalchemy.sql.ddl._DDLCompiles, sqlalchemy.sql.elements._IdentifiedClause, sqlalchemy.sql.elements.GroupedElement, sqlalchemy.sql.elements.TypeClause, sqlalchemy.sql.lambdas.NullLambdaStatement, sqlalchemy.sql.selectable.ForUpdateArg

View In Hierarchy

Base class for elements of a programmatically constructed SQL expression.
Method compare Compare this _expression.ClauseElement to the given _expression.ClauseElement.
Method compile Compile this SQL expression.
Method params Return a copy with _expression.bindparam elements replaced.
Method self​_group Apply a 'grouping' to this _expression.ClauseElement.
Method unique​_params Return a copy with _expression.bindparam elements replaced.
Method __bool__ Undocumented
Method __getstate__ Undocumented
Method __invert__ Undocumented
Method __repr__ Undocumented
Method __str__ 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 ​_compiler Return a compiler appropriate for this ClauseElement, given a Dialect.
Method ​_execute​_on​_connection Undocumented
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 _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 __visit​_name__ Undocumented
Class Variable ​_cache​_key​_traversal Undocumented
Class Variable ​_from​_objects Undocumented
Class Variable ​_is​_bind​_parameter Undocumented
Class Variable ​_is​_clause​_list Undocumented
Class Variable ​_is​_clone​_of Undocumented
Class Variable ​_is​_from​_clause Undocumented
Class Variable ​_is​_from​_container Undocumented
Class Variable ​_is​_immutable Undocumented
Class Variable ​_is​_lambda​_element Undocumented
Class Variable ​_is​_returns​_rows Undocumented
Class Variable ​_is​_select​_container Undocumented
Class Variable ​_is​_select​_statement Undocumented
Class Variable ​_is​_singleton​_constant Undocumented
Class Variable ​_is​_text​_clause Undocumented
Class Variable ​_is​_textual Undocumented
Class Variable ​_order​_by​_label​_element Undocumented
Class Variable bind Undocumented
Class Variable description Undocumented
Class Variable is​_clause​_element Undocumented
Class Variable is​_selectable Undocumented
Class Variable stringify​_dialect Undocumented
Class Variable supports​_execution 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 entity​_namespace Undocumented

Inherited from SQLRole:

Class Variable allows​_lambda Undocumented
Class Variable uses​_inspection Undocumented

Inherited from SupportsWrappingAnnotations:

Method ​_annotate return a copy of this ClauseElement with annotations updated by the given dictionary.
Method ​_deannotate return a copy of this _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):

Property ​_annotations​_cache​_key Undocumented

Inherited from MemoizedHasCacheKey:

Method ​_generate​_cache​_key return a cache key.

Inherited from HasCacheKey (via MemoizedHasCacheKey):

Class Variable inherit​_cache Indicate if this .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 __slots__ 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:

Method ​_copy​_internals Reassign internal elements to be clones of themselves.

Inherited from Traversible:

Method get​_children Return immediate child .visitors.Traversible elements of this .visitors.Traversible.
Method __class​_getitem__ Undocumented
def compare(self, other, **kw):

Compare this _expression.ClauseElement to the given _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 _expression.ColumnElement).

@util.preload_module('sqlalchemy.engine.default')
@util.preload_module('sqlalchemy.engine.url')
def compile(self, bind=None, dialect=None, **kw):

Compile this SQL expression.

The return value is a ~.Compiled object. Calling str() or unicode() on the returned value will yield a string representation of the result. The ~.Compiled object also can return a dictionary of bind parameter names and values using the params accessor.

Parameters
bindAn Engine or Connection from which a Compiled will be acquired. This argument takes precedence over this _expression.ClauseElement's bound engine, if any.
dialectA Dialect instance from which a Compiled will be acquired. This argument takes precedence over the bind argument as well as this _expression.ClauseElement 's bound engine, if any.
**kwUndocumented
column​_keysUsed for INSERT and UPDATE statements, a list of column names which should be present in the VALUES clause of the compiled statement. If None, all columns from the target table object are rendered.
compile​_kwargs

optional dictionary of additional parameters that will be passed through to the compiler within all "visit" methods. This allows any custom flag to be passed through to a custom compilation construct, for example. It is also used for the case of passing the literal_binds flag through:

from sqlalchemy.sql import table, column, select

t = table('t', column('x'))

s = select(t).where(t.c.x == 5)

print(s.compile(compile_kwargs={"literal_binds": True}))
New in version 0.9.0.
def params(self, *optionaldict, **kwargs):

Return a copy with _expression.bindparam elements replaced.

Returns a copy of this ClauseElement with _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=None):

Apply a 'grouping' to this _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 _expression.select constructs when placed into the FROM clause of another _expression.select. (Note that subqueries should be normally created using the _expression.Select.alias method, as many platforms require nested SELECT statements to be named).

As expressions are composed together, the application of 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 self_group method of _expression.ClauseElement just returns self.

def unique_params(self, *optionaldict, **kwargs):

Return a copy with _expression.bindparam elements replaced.

Same functionality as _expression.ClauseElement.params, except adds unique=True to affected bind parameters so that multiple statements can be used.

def __bool__(self):

Undocumented

def __invert__(self):

Undocumented

def __str__(self):
def _clone(self, **kw):

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):

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, compiled_cache=None, column_keys=None, for_executemany=False, schema_translate_map=None, **kw):

Undocumented

def _compiler(self, dialect, **kw):
Return a compiler appropriate for this ClauseElement, given a Dialect.
def _execute_on_connection(self, connection, multiparams, params, execution_options, _force=False):
def _negate_in_binary(self, negated_op, original_op):

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, optionaldict, kwargs):

Undocumented

def _set_propagate_attrs(self, values):

Undocumented

def _ungroup(self):
Return this _expression.ClauseElement without any groupings.
def _with_binary_element_type(self, type_):

in the context of binary expression, convert the type of this object to the one given.

applies only to _expression.ColumnElement classes.

_cache_key_traversal =
_is_bind_parameter: bool =

Undocumented

_is_clause_list: bool =

Undocumented

_is_clone_of =

Undocumented

_is_from_clause: bool =

Undocumented

_is_immutable: bool =

Undocumented

_is_lambda_element: bool =
_is_returns_rows: bool =

Undocumented

_is_select_statement: bool =

Undocumented

_is_singleton_constant: bool =

Undocumented

_is_text_clause: bool =

Undocumented

_order_by_label_element =
is_clause_element: bool =

Undocumented

is_selectable: bool =

Undocumented

supports_execution: bool =

Undocumented

_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.

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.

@property
entity_namespace =