Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 14 variants Column(ColumnRef), Literal(Value), BinaryOp { left: Box<Expr>, op: BinaryOp, right: Box<Expr>, }, UnaryOp { op: UnaryOp, expr: Box<Expr>, }, Function { name: String, args: Vec<Expr>, }, Aggregate { func: AggregateFunc, expr: Option<Box<Expr>>, distinct: bool, }, Between { expr: Box<Expr>, low: Box<Expr>, high: Box<Expr>, }, NotBetween { expr: Box<Expr>, low: Box<Expr>, high: Box<Expr>, }, In { expr: Box<Expr>, list: Vec<Expr>, }, NotIn { expr: Box<Expr>, list: Vec<Expr>, }, Like { expr: Box<Expr>, pattern: String, }, NotLike { expr: Box<Expr>, pattern: String, }, Match { expr: Box<Expr>, pattern: String, }, NotMatch { expr: Box<Expr>, pattern: String, },
}
Expand description

Expression AST node.

Variants§

§

Column(ColumnRef)

Column reference.

§

Literal(Value)

Literal value.

§

BinaryOp

Binary operation.

Fields

§left: Box<Expr>
§right: Box<Expr>
§

UnaryOp

Unary operation.

Fields

§expr: Box<Expr>
§

Function

Function call.

Fields

§name: String
§args: Vec<Expr>
§

Aggregate

Aggregate function.

Fields

§expr: Option<Box<Expr>>
§distinct: bool
§

Between

BETWEEN expression.

Fields

§expr: Box<Expr>
§low: Box<Expr>
§high: Box<Expr>
§

NotBetween

NOT BETWEEN expression.

Fields

§expr: Box<Expr>
§low: Box<Expr>
§high: Box<Expr>
§

In

IN expression.

Fields

§expr: Box<Expr>
§list: Vec<Expr>
§

NotIn

NOT IN expression.

Fields

§expr: Box<Expr>
§list: Vec<Expr>
§

Like

LIKE expression.

Fields

§expr: Box<Expr>
§pattern: String
§

NotLike

NOT LIKE expression.

Fields

§expr: Box<Expr>
§pattern: String
§

Match

MATCH (regex) expression.

Fields

§expr: Box<Expr>
§pattern: String
§

NotMatch

NOT MATCH (regex) expression.

Fields

§expr: Box<Expr>
§pattern: String

Implementations§

Source§

impl Expr

Source

pub fn column( table: impl Into<String>, column: impl Into<String>, index: usize, ) -> Self

Creates a column reference expression.

Source

pub fn literal(value: impl Into<Value>) -> Self

Creates a literal expression.

Source

pub fn eq(left: Expr, right: Expr) -> Self

Creates an equality expression.

Source

pub fn ne(left: Expr, right: Expr) -> Self

Creates a not-equal expression.

Source

pub fn lt(left: Expr, right: Expr) -> Self

Creates a less-than expression.

Source

pub fn le(left: Expr, right: Expr) -> Self

Creates a less-than-or-equal expression.

Source

pub fn gt(left: Expr, right: Expr) -> Self

Creates a greater-than expression.

Source

pub fn ge(left: Expr, right: Expr) -> Self

Creates a greater-than-or-equal expression.

Source

pub fn and(left: Expr, right: Expr) -> Self

Creates an AND expression.

Source

pub fn or(left: Expr, right: Expr) -> Self

Creates an OR expression.

Source

pub fn not(expr: Expr) -> Self

Creates a NOT expression.

Source

pub fn is_null(expr: Expr) -> Self

Creates an IS NULL expression.

Source

pub fn is_not_null(expr: Expr) -> Self

Creates an IS NOT NULL expression.

Source

pub fn count_star() -> Self

Creates a COUNT(*) aggregate.

Source

pub fn count(expr: Expr) -> Self

Creates a COUNT(expr) aggregate.

Source

pub fn sum(expr: Expr) -> Self

Creates a SUM aggregate.

Source

pub fn avg(expr: Expr) -> Self

Creates an AVG aggregate.

Source

pub fn min(expr: Expr) -> Self

Creates a MIN aggregate.

Source

pub fn max(expr: Expr) -> Self

Creates a MAX aggregate.

Source

pub fn gte(left: Expr, right: Expr) -> Self

Creates a greater-than-or-equal expression.

Source

pub fn lte(left: Expr, right: Expr) -> Self

Creates a less-than-or-equal expression.

Source

pub fn between(expr: Expr, low: Expr, high: Expr) -> Self

Creates a BETWEEN expression.

Source

pub fn not_between(expr: Expr, low: Expr, high: Expr) -> Self

Creates a NOT BETWEEN expression.

Source

pub fn in_list(expr: Expr, values: Vec<Value>) -> Self

Creates an IN expression.

Source

pub fn not_in_list(expr: Expr, values: Vec<Value>) -> Self

Creates a NOT IN expression.

Source

pub fn like(expr: Expr, pattern: &str) -> Self

Creates a LIKE expression.

Source

pub fn not_like(expr: Expr, pattern: &str) -> Self

Creates a NOT LIKE expression.

Source

pub fn regex_match(expr: Expr, pattern: &str) -> Self

Creates a MATCH (regex) expression.

Source

pub fn not_regex_match(expr: Expr, pattern: &str) -> Self

Creates a NOT MATCH (regex) expression.

Source

pub fn jsonb_path_eq(expr: Expr, path: &str, value: Value) -> Self

Creates a JSONB path equality expression.

Source

pub fn jsonb_contains(expr: Expr, path: &str) -> Self

Creates a JSONB contains expression.

Source

pub fn jsonb_exists(expr: Expr, path: &str) -> Self

Creates a JSONB exists expression.

Source

pub fn is_equi_join(&self) -> bool

Checks if this is an equi-join condition (column = column).

Source

pub fn is_range_join(&self) -> bool

Checks if this is a range join condition (>, <, >=, <=).

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnwindSafe for Expr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.