Skip to main content

surrealdb_sql/
lib.rs

1//! The abstract syntax tree for SurrealQL.
2//!
3//! This is the shape a query has immediately after parsing, before any
4//! lowering, name resolution, or planning. [`Ast`] is the whole of a parsed
5//! query; [`Expr`] is a single expression within one.
6//!
7//! # Layer
8//!
9//! The AST is the bottom of the language stack. `surrealdb-syn` builds it and
10//! `surrealdb-core` lowers it into the expression layer, so everything this
11//! crate names sits below it: `surrealdb-strand`, `surrealdb-common`,
12//! `surrealdb-types`, `surrealdb-iam`, and the upstream scalar crates
13//! (`chrono`, `uuid`, `rust_decimal`, `regex`, `bytes`, `geo-types`). Nothing
14//! here reaches up into the parser, the expression layer, the catalog, or the
15//! engine.
16//!
17//! Lowering therefore lives with the consumer: core owns the `sql -> expr`
18//! conversions in its `expr::convert` module. The conversions this crate does
19//! own are the ones the orphan rule pins here, between an AST node and its
20//! `surrealdb-types` counterpart.
21//!
22//! # Scope
23//!
24//! The AST is parse-only. No node is persisted, so nothing here carries a
25//! storage-format guarantee and this crate does not depend on `revision`.
26//! Where a vocabulary type also has to be stored, the persisted form is a
27//! separate revisioned twin at the catalog layer and the two are bridged by
28//! `From` in both directions, so a change to how something parses or renders
29//! cannot move the bytes on disk.
30//!
31//! # Stability
32//!
33//! This crate is an internal implementation detail of SurrealDB with no
34//! stability guarantee. It is scheduled for deletion once the greenfield
35//! parser reaches parity and takes over the same layer, so its API surface
36//! should not grow. Depend on `surrealdb` or `surrealdb-core` instead.
37//!
38//! <section class="warning">
39//! <h3>Unstable!</h3>
40//! This crate is <b>SurrealDB internal API</b>. It does not adhere to SemVer and its API is
41//! free to change and break code even between patch versions. If you are looking for a stable
42//! interface to the SurrealDB library please have a look at
43//! <a href="https://crates.io/crates/surrealdb">the Rust SDK</a>.
44//! </section>
45
46pub mod access;
47pub mod access_type;
48pub mod algorithm;
49pub mod analyzer_function;
50pub mod api_method;
51pub mod ast;
52pub mod base;
53pub mod block;
54pub mod builtin_paths;
55pub mod changefeed;
56pub mod closure;
57pub mod cond;
58pub mod constant;
59pub mod cover;
60pub mod data;
61pub mod dir;
62pub mod event_kind;
63pub mod explain;
64pub mod expression;
65pub mod fetch;
66pub mod field;
67pub mod file;
68pub mod filter;
69pub mod function;
70pub mod group;
71pub mod ident;
72pub mod idiom;
73pub mod kind;
74pub mod language;
75pub mod limit;
76pub mod literal;
77pub mod lookup;
78pub mod mock;
79pub mod model;
80pub mod module;
81pub mod operator;
82pub mod order;
83pub mod output;
84pub mod param;
85pub mod part;
86pub mod permission;
87pub mod record_id;
88pub mod reference;
89pub mod scoring;
90pub mod script;
91pub mod split;
92pub mod start;
93pub mod table_name;
94pub mod table_type;
95pub mod tokenizer;
96pub mod user;
97pub mod view;
98pub mod with;
99
100pub mod index;
101pub mod statements;
102
103#[cfg(feature = "arbitrary")]
104pub mod arbitrary;
105
106pub use self::access_type::AccessType;
107pub use self::algorithm::Algorithm;
108pub use self::api_method::ApiMethod;
109// `Ast` is public so embedders (e.g. the server's Postgres listener) can parse
110// a query once and cache it for repeated execution via `Datastore::process*`.
111pub use self::ast::Ast;
112pub use self::ast::{ExplainFormat, TopLevelExpr};
113pub use self::base::Base;
114pub use self::block::Block;
115pub use self::changefeed::ChangeFeed;
116pub use self::closure::Closure;
117pub use self::cond::Cond;
118pub use self::constant::Constant;
119pub use self::cover::CoverStmts;
120pub use self::data::Data;
121pub use self::dir::Dir;
122pub use self::event_kind::EventKind;
123pub use self::explain::Explain;
124pub use self::expression::Expr;
125pub use self::fetch::{Fetch, Fetchs};
126pub use self::field::{Field, Fields};
127pub use self::function::{Function, FunctionCall};
128pub use self::group::{Group, Groups};
129pub use self::ident::Ident;
130pub use self::idiom::Idiom;
131pub use self::index::Index;
132pub use self::kind::Kind;
133pub use self::limit::Limit;
134pub use self::literal::Literal;
135pub use self::lookup::Lookup;
136pub use self::mock::Mock;
137pub use self::model::Model;
138pub use self::module::{ModuleExecutable, ModuleName, SiloExecutable, SurrealismExecutable};
139pub use self::operator::{AssignOperator, BinaryOperator, PostfixOperator, PrefixOperator};
140pub use self::order::Order;
141pub use self::output::Output;
142pub use self::param::Param;
143pub use self::part::Part;
144pub use self::permission::{Permission, Permissions};
145pub use self::record_id::{RecordIdKeyGen, RecordIdKeyLit, RecordIdKeyRangeLit, RecordIdLit};
146pub use self::scoring::Scoring;
147pub use self::script::Script;
148pub use self::split::{Split, Splits};
149pub use self::start::Start;
150pub use self::statements::{
151	CreateStatement, DefineFunctionStatement, DefineIndexStatement, DefineModelStatement,
152	DefineModuleStatement, DeleteStatement, InsertStatement, KillStatement, LiveStatement,
153	RelateStatement, SelectStatement, UpdateStatement, UpsertStatement,
154};
155pub use self::table_name::TableName;
156pub use self::table_type::TableType;
157pub use self::view::View;
158pub use self::with::With;