# 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
```toml
[dependencies]
dapper-guru = "0.1"
```
## Usage
```rust
use dapper_guru::{FromRow, InMemoryConnection, MappingError, Queryable, Row};
struct User { id: i64, name: String, email: Option<String> }
impl FromRow for User {
fn from_row(row: &Row) -> Result<Self, MappingError> {
Ok(User {
id: row.get("id")?,
name: row.get("name")?,
email: row.try_get("email")?,
})
}
}
let conn = InMemoryConnection::with_grids(vec![rows]);
let users: Vec<User> = conn.query("select * from users")?;
```
## 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
```rust
let mut reader = conn.query_multiple("sp_get_all")?;
let users: Vec<User> = reader.read()?;
let counts: Vec<CountView> = reader.read()?;
```
Grids are consumed in order; `is_consumed()` tells when the reader is drained.
## Multi-mapping
```rust
let pairs: Vec<(Post, Author)> =
conn.query_multi_map("select ...", "author_id", |post, author| (post, author))?;
```
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.