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        add_expr,
61        all,
62        and,
63        and3,
64        avg,
65        binary,
66        bind,
67        boolean,
68        case_when,
69        // Expression builders
70        cast,
71        // Function builders
72        coalesce,
73        // Column builders
74        col,
75        concat,
76        cond,
77        // Aggregate builders
78        count,
79        count_distinct,
80        count_filter,
81        count_where,
82        count_where_all,
83        // Condition builders
84        eq,
85        float,
86        func,
87        gt,
88        gte,
89        ilike,
90        in_list,
91        inc,
92        int,
93        interval,
94        is_in,
95        is_not_null,
96        is_null,
97        // JSON builders
98        json,
99        json_obj,
100        json_path,
101        like,
102        lt,
103        lte,
104        max,
105        min,
106        ne,
107        not_in,
108        now,
109        now_minus,
110        now_plus,
111        null,
112        nullif,
113        param,
114        percentage,
115        // Shortcut helpers
116        recent,
117        recent_col,
118        replace,
119        star,
120        sum,
121        // Literal builders
122        text,
123    };
124    pub use crate::ast::*;
125
126    pub use crate::Qail;
127    pub use crate::error::*;
128    pub use crate::parser::parse;
129    pub use crate::transpiler::ToSql;
130}