class=class="cc-str">"cc-cm">// ORM (object/class first) const users = await prisma.user.findMany({ where: { active: true }, select: { id: true, email: true }, take: class="cc-num">10, });
The AST Data Protocol
QAIL keeps queries on a strictly-typed AST path from your application to the database wire. It removes repository boilerplate, preserves security invariants, and gives you instant AutoREST/WebSocket gateways or ultra-fast Rust and Zig runtimes when you need raw database performance.
cargo install qail zig fetch --save ...qail-zig/v0.8.3.tar.gz
Official Support: Rust, Zig, TypeScript, Swift, Kotlin · Latest stable: qail.rs v1.1.0 · qail-zig v0.8.3 · View performance reports at /benchmarks.
let cmd = Qail::get("users")
.select_all()
.filter("active", Eq, true); SELECT * FROM users WHERE active = $1 { "must": [{ "key": "active", "match": true }] } Same requirement, three coding styles. ORM starts from objects, SQL starts from strings, and QAIL starts from typed AST commands.
class=class="cc-str">"cc-cm">// ORM (object/class first) const users = await prisma.user.findMany({ where: { active: true }, select: { id: true, email: true }, take: class="cc-num">10, });
-- SQL (manual text) SELECT id, email FROM users WHERE active = $1 LIMIT $2;
let cmd = Qail::get(class="cc-str">"users") .columns([class="cc-str">"id", class="cc-str">"email"]) .eq(class="cc-str">"active", true) .limit(class="cc-num">10); let rows = driver.fetch_all(&cmd).await?;
class=class="cc-str">"cc-cm">// ORM: team must enforce tenant filter per query const tenantId = auth.tenant_id; const bookings = await prisma.booking.findMany({ where: { tenant_id: tenantId, status: class="cc-str">"paid" }, select: { id: true, total: true }, });
-- SQL: explicit session + policy discipline SET LOCAL app.current_tenant_id = $1; SELECT id, total FROM bookings WHERE tenant_id = $1 AND status = 'paid';
let ctx = RlsContext::tenant(tenant_id); let cmd = Qail::get(class="cc-str">"bookings") .columns([class="cc-str">"id", class="cc-str">"total"]) .eq(class="cc-str">"status", class="cc-str">"paid") .with_rls(&ctx)?; let rows = driver.fetch_all(&cmd).await?;
In many backends, repository and service classes exist mostly to hide string SQL, ORM shape, tenant filters, and response expansion rules. QAIL moves those concerns into typed AST commands, policy checks, gateway expansion, and driver execution. You keep the domain logic that matters, and remove the pass-through data plumbing.
Traditional Stack
// Typical backend layering
router.get("/bookings", auth, async (req) => {
const rows = await bookingService.listPaid(req.tenant.id);
});
class BookingService {
listPaid(tenantId) {
return bookingRepository.findPaidByTenant(tenantId);
}
}
class BookingRepository {
findPaidByTenant(tenantId) {
return db.booking.findMany({
where: { tenant_id: tenantId, status: "paid" },
});
}
} QAIL Stack
// QAIL path
router.get("/bookings", auth, async (req) => {
let ctx = RlsContext::tenant(req.tenant_id);
let cmd = Qail::get("bookings")
.columns(["id", "total", "status"])
.eq("status", "paid")
.with_rls(&ctx)?;
return driver.fetch_all(&cmd).await?;
}); What disappears
Repository classes that only wrap single SQL queries.
Service methods that only pass parameters downward.
Manual tenant filter rules repeated across every query file.
Entire route handlers when AutoREST already maps to the same AST path.
QAIL provides specialized, production-ready execution environments. Use qail.rs for multi-entry API gateways and vector integrations, or qail-zig for uncompromising low-level database driver performance. Review the full methodology in the transparent benchmarks.
The full orchestration layer: qail-core, qail-pg, vector search, API gateway, and schema-driven RLS policy validation. Now stable on the 1.0 line with production-hardened connection pooling and panic-safety guarantees.
Pure-Zig PostgreSQL driver engineered for throughput. Built-in pooling, pipelining, TLS, integration with COPY, and dedicated CLI/LSP tooling.
The diagram below illustrates the shared AST pipeline flowing through the qail.rs architecture.
Parser, transpiler, and type system. Queries are parsed into typed Abstract Syntax Trees (AST) with schema validation before dispatch.
get users fields id, email
where active = true
limit 10 {
"action": "Get",
"table": "users",
"columns": ["id", "email"],
"filters": [{"active": true}]
} Protocol-native PostgreSQL execution. Compiles AST into binary protocol frames with automatic tenant isolation policies.
SELECT id, email FROM users
WHERE active = true
AND tenant_id = $1; Vector and semantic query translation. Maps filter conditions to Qdrant key-match RPC models using the same pipeline contract.
"filter": {
"must": [
{ "key": "active", "match": { "value": true } }
]
} Automatic API surface gateway. Exposes direct AST mappings, automatic relation expansion, and instant HTTP route definitions.
GET /api/users
?active.eq=true
&limit=10 qail.rs now leads the latest canonical native-DSL PostgreSQL matrix against pgx on 14 of 15 throughput slices, all five p50 latency slices, and four of five p99 slices, while qail-zig leads the current matched Zig driver comparison against pg.zig on its own benchmark page. Review the full methodology and raw output in the benchmark index.
Request adapters cleanly normalize REST parameters, text DSL expressions, and binary payloads into one strictly-typed AST. Validation, policy enforcement, query planning, and wire encoding all securely run through the same unified pipeline before database dispatch.
Qail { action: Get, table: "users", cages: [Filter(active = true)] } rewrite: active = true AND tenant_id = $ctx.tenant_id compile AST to driver-specific protocol frames and typed bind values Parse / Bind / Execute Filter + Vector Search RPC The qail.rs core platform targets two production databases with one typed AST, plus built-in cache for hot paths.
Relational • Transactions • ACID
ProductionMoka • TTL • Zero Latency
Built-inIntegrate effortlessly using our official drivers and client SDKs. We provide robust, type-safe tooling for Rust, Zig, TypeScript, Swift, and Kotlin out of the box.
Deterministic migration execution with policy validation, signed receipts, and explicit unsafe override controls.
--force --confirm <token>
Parses .rs, .ts, .js, and .py sources to detect references to columns affected by a migration.
Emits file and line-level diagnostics so affected call-sites can be fixed before migration execution.
Requires --force plus maintainer confirmation before bypassing failed guardrails.
One AST. Protocol bytes. Compile-time safety. Built-in RLS.