pub struct Ast {
pub expressions: Vec<TopLevelExpr>,
}Fields§
§expressions: Vec<TopLevelExpr>Implementations§
Source§impl Ast
impl Ast
Sourcepub fn single_expr(expr: Expr) -> Self
pub fn single_expr(expr: Expr) -> Self
Creates an ast with a signle expression
pub fn num_statements(&self) -> usize
Sourcepub fn is_value_expression(&self) -> bool
pub fn is_value_expression(&self) -> bool
Returns true if this AST is exactly one top-level expression and that
expression describes inert data only: a literal (including objects,
arrays and sets of inert data), a $param reference, or a built-in
constant.
Use this to validate request payloads that are intended to supply
values rather than to execute SurrealQL (e.g. the body of a REST
/key request that is bound to $data). Function calls, idioms,
statements (CREATE/UPDATE/…), blocks, binary expressions and other
executable forms are all rejected, including when nested inside
object or array literals.
pub fn get_let_statements(&self) -> Vec<String>
pub fn add_param(&mut self, name: String)
Sourcepub fn contains_cancel(&self) -> bool
pub fn contains_cancel(&self) -> bool
Whether a top-level CANCEL (transaction rollback) appears in this AST.
Sourcepub fn is_sole_commit(&self) -> bool
pub fn is_sole_commit(&self) -> bool
Whether this AST is exactly a single top-level COMMIT.
Sourcepub fn is_sole_cancel(&self) -> bool
pub fn is_sole_cancel(&self) -> bool
Whether this AST is exactly a single top-level CANCEL.
Sourcepub fn into_execution_units(self) -> Vec<Ast>
pub fn into_execution_units(self) -> Vec<Ast>
Split this query into sequentially executable units: each
non-transactional top-level statement becomes a unit of its own, while
the statements of a BEGIN..COMMIT/CANCEL block stay together as
one unit. A BEGIN without a matching COMMIT/CANCEL keeps the
remainder of the query in its unit.