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 method;
79pub mod mock;
80pub mod model;
81pub mod module;
82pub mod operator;
83pub mod order;
84pub mod output;
85pub mod param;
86pub mod part;
87pub mod permission;
88pub mod read_only;
89pub mod record_id;
90pub mod reference;
91pub mod scoring;
92pub mod script;
93pub mod split;
94pub mod start;
95pub mod table_name;
96pub mod table_type;
97pub mod tokenizer;
98pub mod user;
99pub mod view;
100pub mod with;
101
102pub mod index;
103pub mod statements;
104
105#[cfg(feature = "arbitrary")]
106pub mod arbitrary;
107
108pub use self::access_type::AccessType;
109pub use self::algorithm::Algorithm;
110pub use self::api_method::ApiMethod;
111// `Ast` is public so embedders (e.g. the server's Postgres listener) can parse
112// a query once and cache it for repeated execution via `Datastore::process*`.
113pub use self::ast::Ast;
114pub use self::ast::{ExplainFormat, TopLevelExpr};
115pub use self::base::Base;
116pub use self::block::Block;
117pub use self::changefeed::ChangeFeed;
118pub use self::closure::Closure;
119pub use self::cond::Cond;
120pub use self::constant::Constant;
121pub use self::cover::CoverStmts;
122pub use self::data::Data;
123pub use self::dir::Dir;
124pub use self::event_kind::EventKind;
125pub use self::explain::Explain;
126pub use self::expression::Expr;
127pub use self::fetch::{Fetch, Fetchs};
128pub use self::field::{Field, Fields};
129pub use self::function::{Function, FunctionCall};
130pub use self::group::{Group, Groups};
131pub use self::ident::Ident;
132pub use self::idiom::Idiom;
133pub use self::index::Index;
134pub use self::kind::Kind;
135pub use self::limit::Limit;
136pub use self::literal::Literal;
137pub use self::lookup::Lookup;
138pub use self::mock::Mock;
139pub use self::model::Model;
140pub use self::module::{ModuleExecutable, ModuleName, SiloExecutable, SurrealismExecutable};
141pub use self::operator::{AssignOperator, BinaryOperator, PostfixOperator, PrefixOperator};
142pub use self::order::Order;
143pub use self::output::Output;
144pub use self::param::Param;
145pub use self::part::Part;
146pub use self::permission::{FieldPermissions, Permission, Permissions};
147pub use self::record_id::{RecordIdKeyGen, RecordIdKeyLit, RecordIdKeyRangeLit, RecordIdLit};
148pub use self::scoring::Scoring;
149pub use self::script::Script;
150pub use self::split::{Split, Splits};
151pub use self::start::Start;
152pub use self::statements::{
153	CreateStatement, DefineFunctionStatement, DefineIndexStatement, DefineModelStatement,
154	DefineModuleStatement, DeleteStatement, InsertStatement, KillStatement, LiveStatement,
155	RelateStatement, SelectStatement, UpdateStatement, UpsertStatement,
156};
157pub use self::table_name::TableName;
158pub use self::table_type::TableType;
159pub use self::view::View;
160pub use self::with::With;