Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 17 variants Literal(Literal), Column(ColumnName), Placeholder(u16), Binary { lhs: Box<Expr>, op: BinOp, rhs: Box<Expr>, }, Unary { op: UnOp, expr: Box<Expr>, }, Cast { expr: Box<Expr>, target: CastTarget, }, IsNull { expr: Box<Expr>, negated: bool, }, FunctionCall { name: String, args: Vec<Expr>, }, Like { expr: Box<Expr>, pattern: Box<Expr>, negated: bool, }, WindowFunction { name: String, args: Vec<Expr>, partition_by: Vec<Expr>, order_by: Vec<(Expr, bool)>, frame: Option<WindowFrame>, null_treatment: NullTreatment, }, ScalarSubquery(Box<SelectStatement>), Exists { subquery: Box<SelectStatement>, negated: bool, }, InSubquery { expr: Box<Expr>, subquery: Box<SelectStatement>, negated: bool, }, Extract { field: ExtractField, source: Box<Expr>, }, Array(Vec<Expr>), ArraySubscript { target: Box<Expr>, index: Box<Expr>, }, AnyAll { expr: Box<Expr>, op: BinOp, array: Box<Expr>, is_any: bool, },
}

Variants§

§

Literal(Literal)

§

Column(ColumnName)

§

Placeholder(u16)

v6.1.1 — $N parameter placeholder for the extended query protocol. The number is 1-based per PostgreSQL convention. Evaluation looks up params[N-1] from the prepared-statement bind buffer; out-of-range indices raise a runtime error (same shape as a column-not-found miss).

§

Binary

Fields

§lhs: Box<Expr>
§rhs: Box<Expr>
§

Unary

Fields

§op: UnOp
§expr: Box<Expr>
§

Cast

PG-style expr::TYPE cast. v1.3 supports VECTOR, INT, BIGINT, FLOAT, TEXT, BOOL targets; engine coerces at evaluation time.

Fields

§expr: Box<Expr>
§target: CastTarget
§

IsNull

Postfix IS NULL / IS NOT NULL. Returns BOOL.

Fields

§expr: Box<Expr>
§negated: bool
§

FunctionCall

Function call name(args...). v1.4 supports a small built-in set (length, upper, lower, abs, coalesce); unknown names error at eval time so the parser stays open for v1.5 aggregates.

Fields

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

Like

SQL LIKE predicate. pattern evaluates to text at runtime; wildcards are % (any run) and _ (one char), backslash escapes the next char (so \% matches a literal %).

Fields

§expr: Box<Expr>
§pattern: Box<Expr>
§negated: bool
§

WindowFunction

v4.12 window function call: name(args) OVER (PARTITION BY ... ORDER BY ...). Supports ROW_NUMBER / RANK / DENSE_RANK and the partition-aware aggregates SUM / AVG / COUNT / MIN / MAX. The window frame defaults to “entire partition” for unordered windows and “from start of partition through current row” for ordered windows — no explicit ROWS / RANGE clause in v4.12 MVP.

Fields

§name: String
§args: Vec<Expr>
§partition_by: Vec<Expr>
§order_by: Vec<(Expr, bool)>
§frame: Option<WindowFrame>

v4.20 explicit frame. None means “use the default”: whole-partition when unordered, running aggregate from partition start through current row when ordered.

§null_treatment: NullTreatment

v6.4.2 — IGNORE NULLS / RESPECT NULLS modifier on LAG / LEAD / FIRST_VALUE / LAST_VALUE. Default is Respect (PG / ANSI default — NULLs participate). Other window functions ignore this flag.

§

ScalarSubquery(Box<SelectStatement>)

v4.10 scalar subquery — (SELECT ...) used in expression position. Must return exactly one row × one column at eval time; the engine errors out otherwise. Uncorrelated only — the inner SELECT cannot reference outer columns.

§

Exists

v4.10 [NOT] EXISTS (SELECT ...). Returns Bool. Inner projection is ignored; only row-count matters.

Fields

§negated: bool
§

InSubquery

v4.10 expr [NOT] IN (SELECT ...). Inner SELECT must project exactly one column; membership is tested by Eq against each row’s value (NULL handling follows ANSI: NULL ∈ list ⇒ NULL ; otherwise present ⇒ true).

Fields

§expr: Box<Expr>
§negated: bool
§

Extract

EXTRACT(<field> FROM <source>) — pull an integer component out of a DATE or TIMESTAMP. Parsed as its own AST node because the FROM keyword is what separates the two halves, not a comma.

Fields

§source: Box<Expr>
§

Array(Vec<Expr>)

v7.10.10 — ARRAY[expr, expr, …] array constructor. Each element is evaluated independently; NULLs are allowed. v7.10 supports only single-dimension TEXT[] semantically; non-text elements coerce at engine evaluation time when the surrounding context (column type / cast) makes the target clear.

§

ArraySubscript

v7.10.10 — array subscript arr[i]. PG 1-based; the engine returns NULL for out-of-range indices.

Fields

§target: Box<Expr>
§index: Box<Expr>
§

AnyAll

v7.10.12 — expr op ANY(arr) and expr op ALL(arr). The operator is the comparison binary op (Eq / Ne / Lt / …); the engine desugars: ANY returns true if any element satisfies; ALL returns true only if every element does. NULL handling follows PG’s three-valued logic.

Fields

§expr: Box<Expr>
§array: Box<Expr>
§is_any: bool

true = ANY, false = ALL.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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
Source§

impl Display for Expr

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Expr

Source§

fn eq(&self, other: &Expr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.