Skip to main content

sql_builder/expr/
enum.rs

1use std::borrow::Cow;
2
3mod constructors;
4mod custom;
5pub use custom::CustomExpr;
6pub(crate) use custom::CustomExprPart;
7mod conversions;
8mod subqueries;
9
10use crate::*;
11
12/// An arbitrary, dynamically-typed SQL expression.
13///
14/// It can be used in select fields, where clauses and many other places.
15///
16/// More concreterly, under the hood [`Expr`]s can be:
17///
18/// - Rust values
19/// - SQL identifiers
20/// - SQL function calls
21/// - various operators and sub-queries
22///
23/// If something is not supported here, look into [`BinOper::Custom`],
24/// [`Func::cust`], or [`Expr::cust*`][`Expr::cust_with_values`] as a
25/// workaround, and consider reporting your issue.
26#[derive(Debug, Clone, PartialEq)]
27pub enum Expr {
28    Column(ColumnRef),
29    Tuple(Vec<Expr>),
30    Unary(UnOper, Box<Expr>),
31    FunctionCall(FunctionCall),
32    Binary(Box<Expr>, BinOper, Box<Expr>),
33    SubQuery(Option<SubQueryOper>, Box<SubQueryStatement>),
34    Value(Value),
35    Values(Vec<Value>),
36    Custom(Cow<'static, str>),
37    CustomWithExpr(CustomExpr),
38    /// A construction error deferred until execution.
39    Invalid(crate::error::RenderError),
40    Keyword(Keyword),
41    AsEnum(DynIden, Box<Expr>),
42    Case(Box<CaseStatement>),
43    Constant(Value),
44    TypeName(TypeRef),
45}