Skip to main content

Crate qbrs_sqlx

Crate qbrs_sqlx 

Source
Expand description

Execution integration between qbrs’s query builder and a real Postgres via sqlx. This crate owns only the value-binding and row-decoding glue; query building, SQL rendering, and every compile-time guarantee live in qbrs-core, which stays independent of any async runtime or driver.

Modules§

prelude
Every extension trait that puts a terminal method on a builder, plus the error type a caller’s own signatures have to name and the DecodeRow bound a generic helper over RowQuery has to spell. Result is deliberately absent: a glob-imported alias of that name shadows std::result::Result in every module that follows, and a service layer has its own error type in most of them — write qbrs_sqlx::Result<T> where the alias is wanted. Which trait applies depends on the builder, so importing them one at a time is bookkeeping with no decision in it — and count in particular resolves against Iterator::count with a confusing message until CountExt is in scope.

Enums§

Error
Errors from executing a qbrs query against Postgres via sqlx. An enum rather than a bare sqlx::Error so a qbrs-level misuse is distinguishable from a driver/database error without string-matching a message.

Traits§

CountExt
The bound is on the method, and the impls are per-builder, for the two reasons LoadExt explains.
CountQuery
SELECT count(*) over a query’s FROM/JOIN/WHERE/GROUP BY, with its ORDER BY/LIMIT/OFFSET dropped — a total counts the rows that match, not the page being shown. Returns a number rather than an Option, since a count query always produces exactly one row.
DecodeRow
Decodes a query’s Output positionally out of a PgRow. Keyed on the plain-Rust type a selection produces rather than on the selection itself: erasure leaves only Output, with no Selection impl left to hang decoding off, so this is implemented directly against the closed set of native types.
ExecuteExt
The bound is on the method, and the impls are per-builder, for the two reasons LoadExt explains.
LoadExt
load for the rows, load_one for the first of them, and ExecuteExt::execute where there are none to decode. One trait for every row-producing builder keeps the terminal vocabulary tied to what a statement yields rather than to which builder happens to be in hand.
PreparedCountExt
The bound is on the method, and the impls are per-builder, for the two reasons LoadExt explains.
PreparedExt
The bound is on the method, and the impls are per-builder, for the two reasons LoadExt explains.
PreparedQuery
Runs a prepare!{}-built query, resolving its named placeholders from params first. Separate from LoadExt only because the values arrive at the call rather than being baked into the query: one Prepared is meant to serve many calls, and .resolve() clones the template rather than re-rendering it.
PreparedTotal
A prepared total. Separate from PreparedExt for the reason CountExt is separate from LoadExt: a count produces a number, not rows.
RowQuery
What a row-producing query renders to, and what its rows decode to: a SELECT, a RETURNING clause, an erased DynSelect, a UNION chain. LoadExt is the pair of methods over it, and the split is load-bearing — with the validity bound on the impl instead, an invalid selection makes .load(..) not exist, and the scope error the builder wanted to report is replaced by a method-resolution failure that never mentions the table.
WriteStatement
Every writing statement, rendered: what execute returns is rows affected, whichever of the three it was.

Type Aliases§

Result
This crate’s Result: the same shape as sqlx::Result, with qbrs_sqlx::Error as the fixed error type.