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