pub enum SimpleExpr {
Show 17 variants
Column(ColumnRef),
TableColumn(DynIden, DynIden),
Value(Value),
Unary(UnOper, Box<SimpleExpr>),
Binary(Box<SimpleExpr>, BinOper, Box<SimpleExpr>),
FunctionCall(DynIden, Vec<SimpleExpr>),
SubQuery(Option<SubQueryOper>, Box<SelectStatement>),
Tuple(Vec<SimpleExpr>),
Custom(String),
CustomWithExpr(String, Vec<SimpleExpr>),
Constant(Keyword),
Asterisk,
Case(Box<CaseStatement>),
AsEnum(DynIden, Box<SimpleExpr>),
Cast(Box<SimpleExpr>, DynIden),
Window {
func: Box<SimpleExpr>,
window: WindowStatement,
},
WindowNamed {
func: Box<SimpleExpr>,
name: DynIden,
},
}Expand description
A simple SQL expression.
This enum represents the AST for SQL expressions. Each variant corresponds to a type of SQL expression that can appear in queries.
§Example
use reinhardt_query::SimpleExpr;
// Column reference
let col = SimpleExpr::Column(ColumnRef::column("name"));
// Value literal
let val = SimpleExpr::Value(Value::Int(Some(42)));
// Binary operation (column = 42)
let eq = SimpleExpr::Binary(
Box::new(col),
BinOper::Equal,
Box::new(val),
);Variants§
Column(ColumnRef)
A column reference (e.g., name, users.name, public.users.name)
TableColumn(DynIden, DynIden)
A table-qualified column (legacy format)
Value(Value)
A literal value (e.g., 42, 'hello', TRUE)
Unary(UnOper, Box<SimpleExpr>)
A unary operation (e.g., NOT x)
Binary(Box<SimpleExpr>, BinOper, Box<SimpleExpr>)
A binary operation (e.g., x = y, a AND b, x + y)
FunctionCall(DynIden, Vec<SimpleExpr>)
A function call (e.g., MAX(x), LOWER(name))
SubQuery(Option<SubQueryOper>, Box<SelectStatement>)
A subquery (e.g., (SELECT ...))
The optional operator indicates how the subquery is used:
None: Standalone subquery (e.g., in FROM clause or SELECT list)Some(SubQueryOper): Subquery with operator (e.g., IN, EXISTS, ALL)
Tuple(Vec<SimpleExpr>)
A tuple of expressions (e.g., (1, 2, 3))
Custom(String)
A custom SQL expression (e.g., NOW())
§Security Warning
This variant embeds raw SQL directly into the query. Only use with trusted
input or static SQL strings. For dynamic values, use CustomWithExpr instead.
CustomWithExpr(String, Vec<SimpleExpr>)
A custom SQL expression with parameter placeholders
Constant(Keyword)
A constant (database-specific constant like TRUE, FALSE, NULL)
Asterisk
An asterisk (*)
Case(Box<CaseStatement>)
A CASE WHEN expression
AsEnum(DynIden, Box<SimpleExpr>)
An AS expression with alias (e.g., expr AS alias)
Cast(Box<SimpleExpr>, DynIden)
A CAST expression (e.g., CAST(x AS INTEGER))
Window
A window function with inline window specification
Represents expressions like:
ROW_NUMBER() OVER (PARTITION BY department_id ORDER BY salary DESC)Fields
func: Box<SimpleExpr>The function expression
window: WindowStatementThe window specification
WindowNamed
A window function with named window reference
Represents expressions like:
ROW_NUMBER() OVER window_namewhere window_name is defined in the WINDOW clause.
Implementations§
Source§impl SimpleExpr
impl SimpleExpr
Sourcepub fn binary(self, op: BinOper, right: SimpleExpr) -> Self
pub fn binary(self, op: BinOper, right: SimpleExpr) -> Self
Create a binary operation expression.
Trait Implementations§
Source§impl Clone for SimpleExpr
impl Clone for SimpleExpr
Source§fn clone(&self) -> SimpleExpr
fn clone(&self) -> SimpleExpr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SimpleExpr
impl Debug for SimpleExpr
Source§impl ExprTrait for SimpleExpr
impl ExprTrait for SimpleExpr
Source§fn into_simple_expr(self) -> SimpleExpr
fn into_simple_expr(self) -> SimpleExpr
Source§fn eq<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn eq<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
=). Read moreSource§fn ne<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn ne<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
<>).Source§fn lt<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn lt<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
<).Source§fn lte<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn lte<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
<=).Source§fn gt<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn gt<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
>).Source§fn gte<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn gte<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
>=).Source§fn is_null(self) -> SimpleExpr
fn is_null(self) -> SimpleExpr
Source§fn is_not_null(self) -> SimpleExpr
fn is_not_null(self) -> SimpleExpr
Source§fn between<A, B>(self, a: A, b: B) -> SimpleExpr
fn between<A, B>(self, a: A, b: B) -> SimpleExpr
Source§fn not_between<A, B>(self, a: A, b: B) -> SimpleExpr
fn not_between<A, B>(self, a: A, b: B) -> SimpleExpr
Source§fn is_in<I, V>(self, values: I) -> SimpleExpr
fn is_in<I, V>(self, values: I) -> SimpleExpr
Source§fn is_not_in<I, V>(self, values: I) -> SimpleExpr
fn is_not_in<I, V>(self, values: I) -> SimpleExpr
Source§fn like<V>(self, pattern: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn like<V>(self, pattern: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Source§fn not_like<V>(self, pattern: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn not_like<V>(self, pattern: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Source§fn ilike<V>(self, pattern: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn ilike<V>(self, pattern: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Source§fn not_ilike<V>(self, pattern: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn not_ilike<V>(self, pattern: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
Source§fn starts_with<S>(self, prefix: S) -> SimpleExpr
fn starts_with<S>(self, prefix: S) -> SimpleExpr
Source§fn ends_with<S>(self, suffix: S) -> SimpleExpr
fn ends_with<S>(self, suffix: S) -> SimpleExpr
Source§fn contains<S>(self, substring: S) -> SimpleExpr
fn contains<S>(self, substring: S) -> SimpleExpr
Source§fn and<E>(self, other: E) -> SimpleExprwhere
E: Into<SimpleExpr>,
fn and<E>(self, other: E) -> SimpleExprwhere
E: Into<SimpleExpr>,
Source§fn or<E>(self, other: E) -> SimpleExprwhere
E: Into<SimpleExpr>,
fn or<E>(self, other: E) -> SimpleExprwhere
E: Into<SimpleExpr>,
Source§fn not(self) -> SimpleExpr
fn not(self) -> SimpleExpr
Source§fn add<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn add<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
+).Source§fn sub<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn sub<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
-).Source§fn mul<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn mul<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
*).Source§fn div<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn div<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
/).Source§fn modulo<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn modulo<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
%).Source§fn bit_and<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn bit_and<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
&).Source§fn bit_or<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn bit_or<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
|).Source§fn left_shift<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn left_shift<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
<<).Source§fn right_shift<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
fn right_shift<V>(self, v: V) -> SimpleExprwhere
V: Into<SimpleExpr>,
>>).