pub enum Expr {
Show 22 variants
Param(ParamName),
Column(ColumnRef),
String(String),
Int(i64),
Bool(bool),
Null,
Now,
Default,
BinOp {
left: Box<Expr>,
op: BinOp,
right: Box<Expr>,
},
IsNull {
expr: Box<Expr>,
negated: bool,
},
Like {
expr: Box<Expr>,
pattern: Box<Expr>,
},
ILike {
expr: Box<Expr>,
pattern: Box<Expr>,
},
Any {
expr: Box<Expr>,
array: Box<Expr>,
},
JsonGet {
expr: Box<Expr>,
key: Box<Expr>,
},
JsonGetText {
expr: Box<Expr>,
key: Box<Expr>,
},
Contains {
expr: Box<Expr>,
value: Box<Expr>,
},
KeyExists {
expr: Box<Expr>,
key: Box<Expr>,
},
Cast {
expr: Box<Expr>,
pg_type: PgType,
},
Excluded(ColumnName),
FnCall {
name: String,
args: Vec<Expr>,
},
Count {
table: TableName,
},
Raw(String),
}Expand description
A SQL expression.
Variants§
Param(ParamName)
A parameter placeholder (e.g., $handle -> $1)
Column(ColumnRef)
A column reference
String(String)
A string literal
Int(i64)
An integer literal
Bool(bool)
A boolean literal
Null
NULL
Now
NOW() function
Default
DEFAULT keyword
BinOp
Binary operation (e.g., a = b, a AND b)
IsNull
IS NULL / IS NOT NULL
Like
LIKE pattern match (case-sensitive)
ILike
ILIKE pattern match (case-insensitive)
Any
= ANY(array) for IN checks with array parameter
JsonGet
JSONB -> operator (get object field, returns JSONB)
JsonGetText
JSONB ->> operator (get object field as text)
Contains
@> operator (contains, typically for JSONB)
KeyExists
? operator (key exists, typically for JSONB)
Cast
Type cast (e.g., $1::text[], value::integer)
Excluded(ColumnName)
EXCLUDED.column reference for ON CONFLICT DO UPDATE
FnCall
Function call
Count
COUNT(table.*) for counting related rows
Raw(String)
Raw SQL (escape hatch)
Implementations§
Source§impl Expr
impl Expr
pub fn param(name: ParamName) -> Self
pub fn column(name: ColumnName) -> Self
pub fn qualified_column(table: TableName, column: ColumnName) -> Self
pub fn string(s: impl Into<String>) -> Self
pub fn int(n: i64) -> Self
pub fn bool(b: bool) -> Self
Sourcepub fn is_not_null(self) -> Self
pub fn is_not_null(self) -> Self
Create IS NOT NULL expression
Sourcepub fn ilike(self, pattern: Expr) -> Self
pub fn ilike(self, pattern: Expr) -> Self
Create ILIKE expression (case-insensitive pattern match)
Sourcepub fn json_get(self, key: Expr) -> Self
pub fn json_get(self, key: Expr) -> Self
Create JSONB -> expression (get object field, returns JSONB)
Sourcepub fn json_get_text(self, key: Expr) -> Self
pub fn json_get_text(self, key: Expr) -> Self
Create JSONB ->> expression (get object field as text)
Sourcepub fn contains(self, value: Expr) -> Self
pub fn contains(self, value: Expr) -> Self
Create @> expression (contains, typically for JSONB)
Sourcepub fn key_exists(self, key: Expr) -> Self
pub fn key_exists(self, key: Expr) -> Self
Create ? expression (key exists, typically for JSONB)
Sourcepub fn excluded(column: ColumnName) -> Self
pub fn excluded(column: ColumnName) -> Self
Create an EXCLUDED.column reference for ON CONFLICT DO UPDATE