class BaseExpression: (source)
Known subclasses: django.db.models.expressions.Expression
, django.db.models.expressions.Subquery
, django.db.models.sql.query.Query
Base class for all query expressions.
Method | __getstate__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | as |
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 |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
Return the underlying field types used by this aggregate. |
Method | get |
Undocumented |
Method | prefix |
Undocumented |
Method | relabeled |
Undocumented |
Method | replace |
Undocumented |
Method | resolve |
Provide the chance to do any preprocessing or validation before being added to the query. |
Method | reverse |
Undocumented |
Method | select |
Custom format for select clauses. For example, EXISTS expressions need to be wrapped in CASE WHEN on Oracle. |
Method | set |
Undocumented |
Class Variable | filterable |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | window |
Undocumented |
Property | conditional |
Undocumented |
Property | contains |
Undocumented |
Property | contains |
Undocumented |
Property | contains |
Undocumented |
Property | convert |
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 |
Return the output type of this expressions. |
Static Method | _convert |
Undocumented |
Method | _parse |
Undocumented |
Method | _resolve |
Attempt to infer the output type of the expression. |
Class Variable | _output |
Undocumented |
Property | _output |
Return the output field of this expression, or None if _resolve_output_field() didn't return an output type. |
django.contrib.postgres.fields.ranges.RangeBoundary
, django.db.models.expressions.Case
, django.db.models.expressions.Col
, django.db.models.expressions.CombinedExpression
, django.db.models.expressions.ExpressionWrapper
, django.db.models.expressions.Func
, django.db.models.expressions.OrderBy
, django.db.models.expressions.RawSQL
, django.db.models.expressions.Ref
, django.db.models.expressions.Subquery
, django.db.models.expressions.Value
, django.db.models.expressions.When
, django.db.models.expressions.Window
, django.db.models.expressions.WindowFrame
, django.db.models.lookups.Lookup
, django.db.models.sql.query.Query
Undocumented
django.contrib.postgres.fields.ranges.RangeBoundary
, django.db.models.expressions.Case
, django.db.models.expressions.Col
, django.db.models.expressions.CombinedExpression
, django.db.models.expressions.ExpressionWrapper
, django.db.models.expressions.Func
, django.db.models.expressions.OrderBy
, django.db.models.expressions.RawSQL
, django.db.models.expressions.Ref
, django.db.models.expressions.Star
, django.db.models.expressions.Subquery
, django.db.models.expressions.Value
, django.db.models.expressions.When
, django.db.models.expressions.Window
, django.db.models.expressions.WindowFrame
, django.db.models.fields.json.ContainedBy
, django.db.models.fields.json.DataContains
, django.db.models.fields.json.HasKeyLookup
, django.db.models.lookups.BuiltinLookup
, django.db.models.lookups.YearLookup
, django.db.models.sql.query.Query
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`.
django.db.models.expressions.Case
, django.db.models.expressions.Func
, django.db.models.expressions.Subquery
Undocumented
django.db.models.aggregates.Aggregate
, django.db.models.expressions.Case
, django.db.models.expressions.Col
, django.db.models.expressions.ExpressionWrapper
, django.db.models.expressions.OrderBy
, django.db.models.expressions.RawSQL
, django.db.models.expressions.Ref
, django.db.models.expressions.Subquery
, django.db.models.expressions.Value
, django.db.models.expressions.When
, django.db.models.expressions.Window
, django.db.models.expressions.WindowFrame
, django.db.models.functions.Random
, django.db.models.lookups.Lookup
, django.db.models.sql.query.Query
Undocumented
django.db.models.expressions.Case
, django.db.models.expressions.CombinedExpression
, django.db.models.expressions.ExpressionWrapper
, django.db.models.expressions.Func
, django.db.models.expressions.OrderBy
, django.db.models.expressions.Ref
, django.db.models.expressions.Subquery
, django.db.models.expressions.When
, django.db.models.expressions.Window
, django.db.models.expressions.WindowFrame
, django.db.models.lookups.Lookup
Undocumented
django.db.models.expressions.Col
, django.db.models.expressions.Ref
, django.db.models.sql.query.Query
Undocumented
django.db.models.expressions.Case
, django.db.models.expressions.CombinedExpression
, django.db.models.expressions.Func
, django.db.models.expressions.RawSQL
, django.db.models.expressions.Ref
, django.db.models.expressions.Value
, django.db.models.expressions.When
, django.db.models.lookups.Lookup
, django.db.models.sql.query.Query
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.
Custom format for select clauses. For example, EXISTS expressions need to be wrapped in CASE WHEN on Oracle.
django.db.models.expressions.Case
, django.db.models.expressions.CombinedExpression
, django.db.models.expressions.ExpressionWrapper
, django.db.models.expressions.Func
, django.db.models.expressions.OrderBy
, django.db.models.expressions.Ref
, django.db.models.expressions.Subquery
, django.db.models.expressions.When
, django.db.models.expressions.Window
, django.db.models.expressions.WindowFrame
, django.db.models.lookups.Lookup
Undocumented
django.db.models.aggregates.Aggregate
, django.db.models.functions.window.CumeDist
, django.db.models.functions.window.DenseRank
, django.db.models.functions.window.FirstValue
, django.db.models.functions.window.LagLeadFunction
, django.db.models.functions.window.LastValue
, django.db.models.functions.window.NthValue
, django.db.models.functions.window.Ntile
, django.db.models.functions.window.PercentRank
, django.db.models.functions.window.Rank
, django.db.models.functions.window.RowNumber
Undocumented
django.db.models.aggregates.Aggregate
, django.db.models.expressions.Subquery
, django.db.models.expressions.Window
Undocumented
django.db.models.functions.datetime.TruncBase
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.
django.contrib.postgres.fields.ranges.IsEmpty
, django.contrib.postgres.fields.ranges.LowerInclusive
, django.contrib.postgres.fields.ranges.LowerInfinite
, django.contrib.postgres.fields.ranges.RangeEndsWith
, django.contrib.postgres.fields.ranges.RangeStartsWith
, django.contrib.postgres.fields.ranges.UpperInclusive
, django.contrib.postgres.fields.ranges.UpperInfinite
, django.db.models.aggregates.Count
, django.db.models.expressions.Exists
, django.db.models.expressions.TemporalSubtraction
, django.db.models.functions.Extract
, django.db.models.functions.JSONObject
, django.db.models.functions.Left
, django.db.models.functions.Length
, django.db.models.functions.LPad
, django.db.models.functions.Now
, django.db.models.functions.Ord
, django.db.models.functions.Repeat
, django.db.models.functions.StrIndex
, django.db.models.functions.Substr
, django.db.models.functions.TruncDate
, django.db.models.functions.TruncTime
, django.db.models.functions.window.CumeDist
, django.db.models.functions.window.DenseRank
, django.db.models.functions.window.Ntile
, django.db.models.functions.window.PercentRank
, django.db.models.functions.window.Rank
, django.db.models.functions.window.RowNumber
, django.db.models.lookups.Lookup
, django.db.models.sql.query.Query
Return the output type of this expressions.
django.db.models.expressions.CombinedExpression
, django.db.models.expressions.Subquery
, django.db.models.expressions.Value
, django.db.models.expressions.Window
, django.db.models.functions.Round
, django.db.models.functions.window.LagLeadFunction
, django.db.models.functions.window.NthValue
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.