About this project
qbrs is a type-safe SQL query builder for Rust that combines the benefits of compile-time verification with the flexibility of dynamic query construction. Unlike many builders that force a choice between static safety and runtime dynamism, qbrs checks column and join references at compile time using a flat type-level list, while treating predicate accumulation as a runtime vector. This allows developers to conditionally add filters or loops without needing escape hatches like `.into_boxed()` or `.dynamic()`.
Key features include:
- **Compile-time Safety**: Validates that referenced columns exist within the current query scope. For example, referencing a column from a table that hasn't been joined results in a compile error.
- **Automatic Nullability**: Derives `Option<T>` types for columns on the right side of `LEFT JOIN`s automatically, ensuring type correctness without manual annotations.
- **Column-Keyed Results**: Rows are decoded by column name rather than position, making schema changes safer and code more readable.
- **Comprehensive SQL Support**: Supports `SELECT`, `INSERT`, `UPDATE`, `DELETE`, all join types, `GROUP BY`, `HAVING`, aggregates, `DISTINCT`, upserts, set operations (`UNION`, etc.), window functions, CTEs, and transactions.
- **Dialect Gating**: The SQL dialect is part of the query type, enabling capability checks (e.g., `RETURNING` support) at build time rather than render time.
The project is currently in early stages (v0.1.0/0.2.0) and is explicitly marked as **not production-ready**. It is not an ORM; it does not handle change tracking, identity maps, or object-relational mapping. For those needs, SeaORM is recommended. For raw SQL with compile-time checks, sqlx is suggested. qbrs execution layer is currently limited to Postgres via `qbrs-sqlx`, though MySQL and SQLite rendering are supported and tested in CI.
Notable limitations include no table aliasing, no recursive CTEs, no row locking (`FOR UPDATE`), and no aggregates as window functions. Conditional joining of tables requires erasing types to `DynSelect`, which is a narrow escape hatch. The library is dual-licensed under MIT or Apache-2.0.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.