AkurAI Build
Menu

Public repository / master

AkurAI-Framework / crates/sql/src/lib.rs

Latest change fa37e2544d31a1199954a395f9e5b3ebb237b17f - feat(sql): aggregates (COUNT/SUM/AVG/MIN/MAX) + GROUP BY (gpt-5.5) by Ólafur Búi Ólafsson

//! AkurAI-Framework SQL — pure `std`, zero dependencies.
//!
//! The front half of the query engine: a [`tokenize`]r and a recursive-descent
//! [`parse`]r that turn SQL text into an [`ast`] tree. This crate is
//! **parser-only** — it builds the AST and stops there. Executing that AST over
//! the [`storage`](../../storage) B+tree is a later slice.
//!
//! Supported subset:
//!
//! - `SELECT <cols|aggregates|*> FROM <table> [WHERE <expr>] [GROUP BY <col>] [ORDER BY <col> [ASC|DESC]] [LIMIT <n>]`
//! - `INSERT INTO <table> (<cols>) VALUES (<values>)`
//! - `UPDATE <table> SET <col> = <value> [, <col> = <value>]* [WHERE <expr>]`
//! - `DELETE FROM <table> [WHERE <expr>]`
//! - `CREATE TABLE <table> (<col> <type> [NOT NULL], …)`
//!
//! `WHERE` expressions support comparisons (`= != <> < <= > >=`) over columns
//! and literals, combined with `AND`/`OR`/`NOT` and parentheses, with `AND`
//! binding tighter than `OR`.
//!
//! ```
//! use akurai_sql::{parse, Statement};
//!
//! let stmt = parse("SELECT id, name FROM users WHERE age >= 18 LIMIT 10").unwrap();
//! assert!(matches!(stmt, Statement::Select(_)));
//! ```

#![forbid(unsafe_code)]

pub mod ast;
mod error;
mod lexer;
mod parser;
mod token;

pub use ast::{
    AggregateArg, AggregateExpr, AggregateFunction, ColumnDef, CompareOp, CreateTableStmt,
    DataType, DeleteStmt, Direction, Expr, InsertStmt, Literal, OrderBy, SelectColumn, SelectStmt,
    Statement, UpdateStmt,
};
pub use error::SqlError;
pub use lexer::tokenize;
pub use parser::parse;
pub use token::{Keyword, SpannedToken, Token};