dapper-guru
Dapper-style micro-ORM mapping for Rust — the FromRow trait, case/underscore-insensitive column lookup, typed column coercion, the query_first/query_single family, a QueryMultiple grid reader, multi-mapping with splitOn, dynamic parameters and an InMemoryConnection for tests. One dependency (serde_json).
Install
[]
= "0.1"
Usage
use ;
let conn = with_grids;
let users: = conn.query?;
The query family
query, query_first (NoRow on empty), query_first_or_default, query_single (TooManyRows on duplicates), query_single_or_default, plus *_with variants taking parameters. query_scalar::<T> reads a typed first column of the first row.
Column lookup and coercion
row.get("UserName") matches user_name — case, _ and - insensitive, like Dapper's MatchNamesWithUnderscores. Numbers coerce across widths and from strings, bool accepts 1/0/true/false, Option<T> maps SQL NULL, Vec<u8> reads arrays or text bytes.
QueryMultiple
let mut reader = conn.query_multiple?;
let users: = reader.read?;
let counts: = reader.read?;
Grids are consumed in order; is_consumed() tells when the reader is drained.
Multi-mapping
let pairs: =
conn.query_multi_map?;
The row splits at the splitOn column; each part maps independently.
Parameters
parameters(&[("id", json!(1))]) or ParametersBuilder::new().set(...); commands executed against InMemoryConnection are logged into executed for assertions.
What is verified
Integration tests cover struct mapping, insensitive lookup, numeric/bool coercion, every query_* variant including error cases, execute affected-row logging, typed scalars with NULL, ordered grid reading, multi-mapping split, not-found errors and parameter flow.