Skip to main content

qail_core/
lib.rs

1//! Type-safe SQL query builder with AST-native design.
2//!
3//! Build queries as typed AST, not strings. Zero SQL injection risk.
4//!
5//! ```ignore
6//! use qail_core::ast::{Qail, Operator};
7//! let cmd = Qail::get("users").column("name").filter("active", Operator::Eq, true);
8//! ```
9
10/// Native vertical access policy checks for QAIL commands.
11pub mod access;
12#[cfg(feature = "analyzer")]
13pub mod analyzer;
14/// Abstract syntax tree types.
15pub mod ast;
16/// Schema branching.
17pub mod branch;
18/// Build-time schema validation.
19pub mod build;
20/// Code generation for typed schema modules.
21pub mod codegen;
22/// Configuration types.
23pub mod config;
24/// Error types.
25pub mod error;
26/// SQL formatter.
27pub mod fmt;
28/// Database migration types.
29pub mod migrate;
30/// Query normalization and optimizer support.
31pub mod optimizer;
32/// QAIL query parser.
33pub mod parser;
34/// Row-level security context.
35pub mod rls;
36/// AST structural sanitization for untrusted binary input.
37pub mod sanitize;
38/// Schema definitions for validation.
39pub mod schema;
40/// Filesystem schema source loader (`schema.qail` or modular `schema/`).
41pub mod schema_source;
42/// SQL transpiler (AST to SQL).
43pub mod transpiler;
44/// Typed column and table traits.
45pub mod typed;
46/// Schema validator.
47pub mod validator;
48/// Versioned AST wire codecs (text + QWB2 binary).
49pub mod wire;
50
51#[cfg(test)]
52mod proptest;
53
54pub use parser::parse;
55
56/// Ergonomic alias for Qail - the primary query builder type.
57pub type Qail = ast::Qail;
58
59/// Common re-exports for convenient wildcard imports.
60pub mod prelude {
61    pub use crate::ast::builders::{
62        // Extension traits
63        ExprExt,
64        add_expr,
65        all,
66        and,
67        and3,
68        avg,
69        binary,
70        bind,
71        boolean,
72        case_when,
73        // Expression builders
74        cast,
75        // Function builders
76        coalesce,
77        // Column builders
78        col,
79        concat,
80        cond,
81        // Aggregate builders
82        count,
83        count_distinct,
84        count_filter,
85        count_where,
86        count_where_all,
87        // Condition builders
88        eq,
89        float,
90        func,
91        gt,
92        gte,
93        ilike,
94        in_list,
95        inc,
96        int,
97        interval,
98        is_in,
99        is_not_null,
100        is_null,
101        // JSON builders
102        json,
103        json_obj,
104        json_path,
105        like,
106        lt,
107        lte,
108        max,
109        min,
110        ne,
111        not_in,
112        now,
113        now_minus,
114        now_plus,
115        null,
116        nullif,
117        param,
118        percentage,
119        // Shortcut helpers
120        recent,
121        recent_col,
122        replace,
123        star,
124        sum,
125        // Literal builders
126        text,
127    };
128    pub use crate::ast::*;
129
130    pub use crate::Qail;
131    pub use crate::access::*;
132    pub use crate::error::*;
133    pub use crate::parser::parse;
134    pub use crate::transpiler::ToSql;
135}