class documentation

Base class for all query expressions.

Method __getstate__ Undocumented
Method __init__ Undocumented
Method as_sql Responsible for returning a (sql, [params]) tuple to be included in the current query.
Method asc Undocumented
Method copy Undocumented
Method desc Undocumented
Method flatten Recursively yield this expression and all subexpressions, in depth-first order.
Method get_db_converters Undocumented
Method get_group_by_cols Undocumented
Method get_lookup Undocumented
Method get_source_expressions Undocumented
Method get_source_fields Return the underlying field types used by this aggregate.
Method get_transform Undocumented
Method prefix_references Undocumented
Method relabeled_clone Undocumented
Method replace_references Undocumented
Method resolve_expression Provide the chance to do any preprocessing or validation before being added to the query.
Method reverse_ordering Undocumented
Method select_format Custom format for select clauses. For example, EXISTS expressions need to be wrapped in CASE WHEN on Oracle.
Method set_source_expressions Undocumented
Class Variable filterable Undocumented
Class Variable is_summary Undocumented
Class Variable window_compatible Undocumented
Property conditional Undocumented
Property contains_aggregate Undocumented
Property contains_column_references Undocumented
Property contains_over_clause Undocumented
Property convert_value Expressions provide their own converters because users have the option of manually specifying the output_field which may be a different type from the one the database returns.
Property field Undocumented
Property output_field Return the output type of this expressions.
Static Method _convert_value_noop Undocumented
Method _parse_expressions Undocumented
Method _resolve_output_field Attempt to infer the output type of the expression.
Class Variable _output_field_resolved_to_none Undocumented
Property _output_field_or_none Return the output field of this expression, or None if _resolve_output_field() didn't return an output type.
def __getstate__(self): (source)

Undocumented

def as_sql(self, compiler, connection): (source)

Responsible for returning a (sql, [params]) tuple to be included in the current query. Different backends can provide their own implementation, by providing an `as_{vendor}` method and patching the Expression: ``` def override_as_sql(self, compiler, connection): # custom logic return super().as_sql(compiler, connection) setattr(Expression, 'as_' + connection.vendor, override_as_sql) ``` Arguments: * compiler: the query compiler responsible for generating the query. Must have a compile method, returning a (sql, [params]) tuple. Calling compiler(value) will return a quoted `value`. * connection: the database connection used for the current query. Return: (sql, params) Where `sql` is a string containing ordered sql parameters to be replaced with the elements of the list `params`.

def asc(self, **kwargs): (source)

Undocumented

def desc(self, **kwargs): (source)

Undocumented

def flatten(self): (source)

Recursively yield this expression and all subexpressions, in depth-first order.

def get_db_converters(self, connection): (source)

Undocumented

def get_lookup(self, lookup): (source)

Undocumented

def get_source_fields(self): (source)

Return the underlying field types used by this aggregate.

def get_transform(self, name): (source)

Undocumented

def prefix_references(self, prefix): (source)

Undocumented

def replace_references(self, references_map): (source)

Undocumented

def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False): (source)

Provide the chance to do any preprocessing or validation before being added to the query. Arguments: * query: the backend query implementation * allow_joins: boolean allowing or denying use of joins in this query * reuse: a set of reusable joins for multijoins * summarize: a terminal aggregate clause * for_save: whether this expression about to be used in a save or update Return: an Expression to be added to the query.

def reverse_ordering(self): (source)

Undocumented

def select_format(self, compiler, sql, params): (source)

Custom format for select clauses. For example, EXISTS expressions need to be wrapped in CASE WHEN on Oracle.

filterable: bool = (source)

Undocumented

is_summary: bool = (source)

Undocumented

@cached_property
contains_column_references = (source)

Undocumented

@cached_property
contains_over_clause = (source)

Undocumented

Expressions provide their own converters because users have the option of manually specifying the output_field which may be a different type from the one the database returns.

Undocumented

@staticmethod
def _convert_value_noop(value, expression, connection): (source)

Undocumented

def _parse_expressions(self, *expressions): (source)

Undocumented

def _resolve_output_field(self): (source)

Attempt to infer the output type of the expression. As a guess, if the output fields of all source fields match then simply infer the same type here. If a source's output field resolves to None, exclude it from this check. If all sources are None, then an error is raised higher up the stack in the output_field property.

_output_field_resolved_to_none: bool = (source)

Undocumented

@cached_property
_output_field_or_none = (source)

Return the output field of this expression, or None if _resolve_output_field() didn't return an output type.