Represent any SQL expression or statement as a single, recursive AST node.
Expression is the root type of the polyglot AST. Every parsed SQL
construct -- from a simple integer literal to a multi-CTE query with
window functions -- is represented as a variant of this enum.
Variants are organized into logical groups (see the module-level docs).
Most non-trivial variants box their payload so that size_of::<Expression>()
stays small (currently two words: tag + pointer).
Constructing Expressions
Use the convenience constructors on impl Expression for common cases:
use polyglot_sql::expressions::Expression;
let col = Expression::column("id");
let lit = Expression::number(42);
let star = Expression::star();
Generating SQL
let expr = Expression::column("name");
assert_eq!(expr.sql(), "name");
Represent any SQL expression or statement as a single, recursive AST node.
Expressionis the root type of the polyglot AST. Every parsed SQL construct -- from a simple integer literal to a multi-CTE query with window functions -- is represented as a variant of this enum.Variants are organized into logical groups (see the module-level docs). Most non-trivial variants box their payload so that
size_of::<Expression>()stays small (currently two words: tag + pointer).Constructing Expressions
Use the convenience constructors on
impl Expressionfor common cases:Generating SQL