pub enum Expr {
Show 17 variants
Column(Column),
Value(Value),
Binary {
op: BinaryOp,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
Unary {
op: UnaryOp,
expr: Box<Expr>,
},
And(Vec<Expr>),
Or(Vec<Expr>),
Lookup {
expr: Box<Expr>,
lookup: Lookup,
},
Exists(Box<QueryPlan>),
Subquery(Box<QueryPlan>),
Func {
func: Function,
args: Vec<Expr>,
},
Cast {
expr: Box<Expr>,
ty: SqlType,
},
Case {
branches: Vec<(Expr, Expr)>,
otherwise: Option<Box<Expr>>,
},
Aggregate(Aggregate),
Window(Box<Window>),
DatePart {
part: DatePart,
expr: Box<Expr>,
},
OuterRef(Column),
Related(RelatedColumn),
}Expand description
Expression tree node.
Variants§
Column(Column)
Column reference (Django F).
Value(Value)
Literal, always bound as a parameter.
Binary
Binary operation.
Unary
Unary operation.
And(Vec<Expr>)
Conjunction of all children (empty = TRUE).
Or(Vec<Expr>)
Disjunction of all children (empty = FALSE).
Lookup
Lookup applied to an expression.
Exists(Box<QueryPlan>)
EXISTS (subquery).
Subquery(Box<QueryPlan>)
Scalar subquery.
Func
Scalar function call.
Cast
CAST(expr AS type).
Case
Searched CASE WHEN .. THEN .. [ELSE ..] END.
Fields
Aggregate(Aggregate)
Aggregate function (COUNT, SUM, …).
Window(Box<Window>)
Window function with its OVER (..) clause.
DatePart
Date or time component of a temporal expression.
OuterRef(Column)
Column of the enclosing query, used inside a correlated subquery.
Related(RelatedColumn)
Column reached through foreign keys; resolved into joins by
QueryPlan::resolve_relations.
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn outer(name: impl Into<Ident>) -> Self
pub fn outer(name: impl Into<Ident>) -> Self
Reference to a column of the enclosing query (Django OuterRef).
Sourcepub fn subquery(plan: QueryPlan) -> Self
pub fn subquery(plan: QueryPlan) -> Self
Scalar subquery: plan must select exactly one column and one row.
Sourcepub fn eq(self, rhs: impl Into<Expr>) -> Self
pub fn eq(self, rhs: impl Into<Expr>) -> Self
self = rhs. A NULL right-hand side compiles to IS NULL.
Sourcepub fn ne(self, rhs: impl Into<Expr>) -> Self
pub fn ne(self, rhs: impl Into<Expr>) -> Self
self <> rhs. A NULL right-hand side compiles to IS NOT NULL.
Sourcepub fn in_subquery(self, plan: QueryPlan) -> Self
pub fn in_subquery(self, plan: QueryPlan) -> Self
Membership in the single column selected by plan.
Sourcepub fn regex(self, pattern: impl Into<String>) -> Self
pub fn regex(self, pattern: impl Into<String>) -> Self
Regex match (requires Feature::Regex).
Sourcepub fn children(&self) -> Vec<&Expr>
pub fn children(&self) -> Vec<&Expr>
Direct sub-expressions (subquery plans are reached through
subplan instead).
Sourcepub fn children_mut(&mut self) -> Vec<&mut Expr>
pub fn children_mut(&mut self) -> Vec<&mut Expr>
Mutable counterpart of children.
Sourcepub fn subplan(&self) -> Option<&QueryPlan>
pub fn subplan(&self) -> Option<&QueryPlan>
The nested query of EXISTS, a scalar subquery or IN (subquery).
Sourcepub fn subplan_mut(&mut self) -> Option<&mut QueryPlan>
pub fn subplan_mut(&mut self) -> Option<&mut QueryPlan>
Mutable counterpart of subplan.
Sourcepub fn contains_aggregate(&self) -> bool
pub fn contains_aggregate(&self) -> bool
Whether this expression computes an aggregate over the query’s rows
(so a filter on it belongs in HAVING). Aggregates inside window
functions and subqueries do not count.
Sourcepub fn contains_window(&self) -> bool
pub fn contains_window(&self) -> bool
Whether this expression contains a window function.
Source§impl Expr
impl Expr
Sourcepub fn has_foreign_origin(&self, origin: PlanOrigin) -> bool
pub fn has_foreign_origin(&self, origin: PlanOrigin) -> bool
Whether a subquery inside this expression was built against a
database other than origin.
Sourcepub fn required_features(&self) -> Vec<Feature>
pub fn required_features(&self) -> Vec<Feature>
Features this expression (including nested subqueries) needs.