Enum Expression

Source
pub enum Expression<'a> {
Show 22 variants Binary { op: BinaryOperator, op_span: Span, lhs: Box<Expression<'a>>, rhs: Box<Expression<'a>>, }, Unary { op: UnaryOperator, op_span: Span, operand: Box<Expression<'a>>, }, Subquery(Box<Statement<'a>>), Null(Span), Bool(bool, Span), String(SString<'a>), Integer((u64, Span)), ListHack((usize, Span)), Float((f64, Span)), Function(Function<'a>, Vec<Expression<'a>>, Span), WindowFunction { function: Function<'a>, args: Vec<Expression<'a>>, function_span: Span, over_span: Span, window_spec: WindowSpec<'a>, }, Identifier(Vec<IdentifierPart<'a>>), Arg((usize, Span)), Exists(Box<Statement<'a>>), In { lhs: Box<Expression<'a>>, rhs: Vec<Expression<'a>>, in_span: Span, not_in: bool, }, Is(Box<Expression<'a>>, Is, Span), Invalid(Span), Case { case_span: Span, value: Option<Box<Expression<'a>>>, whens: Vec<When<'a>>, else_: Option<(Span, Box<Expression<'a>>)>, end_span: Span, }, Cast { cast_span: Span, expr: Box<Expression<'a>>, as_span: Span, type_: DataType<'a>, }, Count { count_span: Span, distinct_span: Option<Span>, expr: Box<Expression<'a>>, }, GroupConcat { group_concat_span: Span, distinct_span: Option<Span>, expr: Box<Expression<'a>>, }, Variable { global: Option<Span>, session: Option<Span>, dot: Option<Span>, variable: Variable<'a>, variable_span: Span, },
}
Expand description

Representation of an expression

Variants§

§

Binary

Expression with binary operator

Fields

§op: BinaryOperator

The operator to apply

§op_span: Span

The span of the operator

§lhs: Box<Expression<'a>>

Expression on the left hand side

§rhs: Box<Expression<'a>>

Expression on the right hand side

§

Unary

Expression with a unary (prefix) operator

Fields

§op: UnaryOperator

The operator to apply

§op_span: Span

The span of the operator

§operand: Box<Expression<'a>>

The expression on the right hand side

§

Subquery(Box<Statement<'a>>)

Subquery expression

§

Null(Span)

Literal NULL expression

§

Bool(bool, Span)

Literal bool expression “TRUE” or “FALSE”

§

String(SString<'a>)

Literal string expression, the SString contains the represented string with escaping removed

§

Integer((u64, Span))

Literal integer expression

§

ListHack((usize, Span))

Literal LIST

§

Float((f64, Span))

Literal floating point expression

§

Function(Function<'a>, Vec<Expression<'a>>, Span)

Function call expression,

§

WindowFunction

A window function call expression

Fields

§function: Function<'a>
§args: Vec<Expression<'a>>
§function_span: Span
§over_span: Span
§window_spec: WindowSpec<'a>
§

Identifier(Vec<IdentifierPart<'a>>)

Identifier pointing to column

§

Arg((usize, Span))

Input argument to query, the first argument is the occurrence number of the argumnet

§

Exists(Box<Statement<'a>>)

Exists expression

§

In

In expression

Fields

§lhs: Box<Expression<'a>>

Left hand side expression

§rhs: Vec<Expression<'a>>

Right hand side expression

§in_span: Span

Span of “IN” or “NOT IN”

§not_in: bool

True if not in

§

Is(Box<Expression<'a>>, Is, Span)

Is expression

§

Invalid(Span)

Invalid expression, returned on recovery of a parse error

§

Case

Case expression

Fields

§case_span: Span

Span of “CASE”

§value: Option<Box<Expression<'a>>>

Optional value to switch over

§whens: Vec<When<'a>>

When parts

§else_: Option<(Span, Box<Expression<'a>>)>

Span of “ELSE” and else value if specified

§end_span: Span

Span of “END”

§

Cast

Cast expression

Fields

§cast_span: Span

Span of “CAST”

§expr: Box<Expression<'a>>

Value to cast

§as_span: Span

Span of “AS”

§type_: DataType<'a>

Type to cast to

§

Count

Count expression

Fields

§count_span: Span

Span of “COUNT”

§distinct_span: Option<Span>

Span of “DISTINCT” if specified

§expr: Box<Expression<'a>>

Expression to count

§

GroupConcat

Group contat expression

Fields

§group_concat_span: Span

Span of “GROUP_CONCAT”

§distinct_span: Option<Span>

Span of “DISTINCT” if specified

§expr: Box<Expression<'a>>

Expression to count

§

Variable

Variable expression

Fields

§global: Option<Span>

Span of “@@GLOBAL”

§session: Option<Span>

Span of “@@SESSION”

§dot: Option<Span>

Span of ‘.’

§variable: Variable<'a>

variable

§variable_span: Span

Trait Implementations§

Source§

impl<'a> Clone for Expression<'a>

Source§

fn clone(&self) -> Expression<'a>

Returns a copy 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<'a> Debug for Expression<'a>

Source§

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

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

impl<'a> Spanned for Expression<'a>

Source§

fn span(&self) -> Span

Compute byte span of an ast fragment
Source§

fn join_span(&self, other: &impl OptSpanned) -> Span

Compute the minimal span containing both self and other

Auto Trait Implementations§

§

impl<'a> Freeze for Expression<'a>

§

impl<'a> RefUnwindSafe for Expression<'a>

§

impl<'a> Send for Expression<'a>

§

impl<'a> Sync for Expression<'a>

§

impl<'a> Unpin for Expression<'a>

§

impl<'a> UnwindSafe for Expression<'a>

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> OptSpanned for T
where T: Spanned,

Source§

fn opt_span(&self) -> Option<Range<usize>>

Compute an optional byte span of an ast fragment
Source§

fn opt_join_span(&self, other: &impl OptSpanned) -> Option<Span>

Compute the minimal span containing both self and other if either is missing return the other
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.