pub enum Expr {
Show 34 variants
Literal(Literal),
Param(Param),
Idiom(Idiom),
Table(TableName),
Mock(Mock),
Block(Box<Block>),
Constant(Constant),
Prefix {
op: PrefixOperator,
expr: Box<Expr>,
},
Postfix {
expr: Box<Expr>,
op: PostfixOperator,
},
Binary {
left: Box<Expr>,
op: BinaryOperator,
right: Box<Expr>,
},
FunctionCall(Box<FunctionCall>),
Closure(Box<ClosureExpr>),
Break,
Continue,
Return(Box<OutputStatement>),
Throw(Box<Expr>),
IfElse(Box<IfelseStatement>),
Select(Box<SelectStatement>),
Create(Box<CreateStatement>),
Update(Box<UpdateStatement>),
Upsert(Box<UpsertStatement>),
Delete(Box<DeleteStatement>),
Relate(Box<RelateStatement>),
Insert(Box<InsertStatement>),
Define(Box<DefineStatement>),
Remove(Box<RemoveStatement>),
Rebuild(Box<RebuildStatement>),
Alter(Box<AlterStatement>),
Info(Box<InfoStatement>),
Foreach(Box<ForeachStatement>),
Let(Box<SetStatement>),
Sleep(Box<SleepStatement>),
Explain {
format: ExplainFormat,
analyze: bool,
statement: Box<Expr>,
},
Match(Box<MatchPlan>),
}Variants§
Literal(Literal)
Param(Param)
Idiom(Idiom)
Table(TableName)
Mock(Mock)
Block(Box<Block>)
Constant(Constant)
Prefix
Postfix
Binary
FunctionCall(Box<FunctionCall>)
Closure(Box<ClosureExpr>)
Break
Continue
Return(Box<OutputStatement>)
Throw(Box<Expr>)
IfElse(Box<IfelseStatement>)
Select(Box<SelectStatement>)
Create(Box<CreateStatement>)
Update(Box<UpdateStatement>)
Upsert(Box<UpsertStatement>)
Delete(Box<DeleteStatement>)
Relate(Box<RelateStatement>)
Insert(Box<InsertStatement>)
Define(Box<DefineStatement>)
Remove(Box<RemoveStatement>)
Rebuild(Box<RebuildStatement>)
Alter(Box<AlterStatement>)
Info(Box<InfoStatement>)
Foreach(Box<ForeachStatement>)
Let(Box<SetStatement>)
Sleep(Box<SleepStatement>)
Explain
Match(Box<MatchPlan>)
An GQL MATCH query, lowered to its declarative binding-table plan.
Only constructed by the GQL lowering at top level. It runs exclusively
under the streaming execution planner; see the compute and
From<expr::Expr> for sql::Expr arms for the invariants it relies on.
Implementations§
Source§impl Expr
impl Expr
pub fn from_public_value(value: PublicValue) -> Self
Source§impl Expr
impl Expr
Sourcepub fn as_static_value(&self) -> Option<Value>
pub fn as_static_value(&self) -> Option<Value>
The value this expression denotes, when it denotes one without being evaluated.
Only a literal can answer this; every other form either reads the
environment or needs the evaluator, so it answers None. See
Literal::as_static_value for the contract the result upholds.
Narrower than Self::is_static, which is also true of expressions
that are computable without the environment but still need evaluating
(arithmetic on literals, say).
Sourcepub fn is_static(&self) -> bool
pub fn is_static(&self) -> bool
Checks if a expression is ‘pure’ i.e. does not rely on the environment.
pub fn to_idiom(&self) -> Idiom
pub fn to_raw_string(&self) -> String
Source§impl Expr
impl Expr
Sourcepub fn to_stored_sql(&self) -> String
pub fn to_stored_sql(&self) -> String
Renders the canonical SurrealQL text a catalog definition stores for
this expression (e.g. a StoredFieldDefinition.value), matching exactly
what the old sql::Expr-embedding definition used to render when
nested after a clause keyword (VALUE, ASSERT, WHEN, …) —
including the parenthesization CoverStmts applies to statement-shaped
sub-expressions (e.g. a nested SELECT), so the stored text is safe to
splice back in after that keyword with no further wrapping.
Expr::Match never reaches a stored definition (see ToSql’s carve-out
above), so unlike ToSql::fmt_sql this does not special-case it.
Source§impl Expr
impl Expr
Sourcepub fn function_facts(&self) -> FunctionFacts
pub fn function_facts(&self) -> FunctionFacts
Extract this tree’s FunctionFacts.
Source§impl Expr
impl Expr
Sourcepub fn contains_mutation(&self) -> bool
pub fn contains_mutation(&self) -> bool
Whether this expression’s own tree contains a data-modifying statement, looking through subqueries, idiom parts, blocks and closure bodies.
A call to a user-defined function, script, module or silo is opaque: its body lives outside this expression, and is left to the runtime write refusal. Arguments to such a call are walked, since they are evaluated at the call site.
Trait Implementations§
Source§impl DeserializeRevisioned for Expr
impl DeserializeRevisioned for Expr
impl Eq for Expr
impl LengthPrefixedBytes for Expr
Source§impl Revisioned for Expr
impl Revisioned for Expr
Source§impl SerializeRevisioned for Expr
impl SerializeRevisioned for Expr
Source§impl SkipRevisioned for Expr
impl SkipRevisioned for Expr
fn skip_revisioned<R: Read>(reader: &mut R) -> Result<(), Error>
Source§fn skip_revisioned_slice(r: &mut SliceReader<'_>) -> Result<(), Error>
fn skip_revisioned_slice(r: &mut SliceReader<'_>) -> Result<(), Error>
SliceReader without allocating a buffer for bulk segments. Read moreimpl StructuralPartialEq for Expr
Source§impl<V: MutVisitor> VisitMut<V> for Expr
impl<V: MutVisitor> VisitMut<V> for Expr
Source§impl WalkRevisioned for Expr
impl WalkRevisioned for Expr
Source§type Walker<'r, R: BorrowedReader + 'r> = LeafWalker<'r, Expr, R>
type Walker<'r, R: BorrowedReader + 'r> = LeafWalker<'r, Expr, R>
walk_revisioned. Read moreSource§fn walk_revisioned<'r, R: BorrowedReader>(
reader: &'r mut R,
) -> Result<Self::Walker<'r, R>, Error>
fn walk_revisioned<'r, R: BorrowedReader>( reader: &'r mut R, ) -> Result<Self::Walker<'r, R>, Error>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.