qail-core
The AST-native query builder — No SQL strings, no ORM magic, just type-safe expressions.
Why AST-Native?
| Approach | How it works | SQL Injection |
|---|---|---|
| Raw SQL (sqlx) | String literals: "SELECT * FROM users" |
⚠️ Possible |
| ORM (diesel, sea-orm) | Macros generate SQL at compile time | ✅ Safe |
| AST-Native (qail) | Typed AST → Wire protocol bytes | ✅ Impossible |
QAIL builds queries as an Abstract Syntax Tree that compiles directly to database wire protocol. There's no SQL string generation step—SQL injection isn't just prevented, it's structurally impossible.
Installation
[]
= "0.9"
Quick Start
use ;
use *;
// Build a query as typed AST
let cmd = get
.columns
.filter
.order_by
.limit;
// Use with qail-pg driver
let rows = driver.fetch_all.await?;
Ergonomic Expression Builders
use *;
// Aggregates with FILTER
count_filter.alias
// Time expressions
now_minus // NOW() - INTERVAL '24 hours'
// CASE WHEN
case_when
.otherwise
.alias
// Type casting
cast
Features
- Type-safe expressions — Compile-time checked query building
- Ergonomic builders —
count(),sum(),case_when(),now_minus() - Full SQL support — CTEs, JOINs, DISTINCT ON, aggregates with FILTER
- JSON operators —
->,->>,@>,? - Schema parser — Parse DDL into structured AST
Ecosystem
| Crate | Purpose |
|---|---|
| qail-core | AST builder, parser, expression helpers |
| qail-pg | PostgreSQL driver (AST → wire protocol) |
| qail | CLI tool for migrations and schema ops |
License
MIT