dapper-guru 0.1.0

Dapper-style micro-ORM mapping for Rust - FromRow trait, case/underscore-insensitive column lookup, typed column coercion, query_first/single family, QueryMultiple grid reader, multi-mapping with splitOn, DynamicParameters and an InMemoryConnection
Documentation
  • Coverage
  • 0%
    0 out of 75 items documented0 out of 57 items with examples
  • Size
  • Source code size: 48.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 996.3 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • StarcevAlexander/dapper-guru
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • StarcevAlexander

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

[dependencies]
dapper-guru = "0.1"

Usage

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

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

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.