Quarry Docs
GitHub
Reference

Scanning Helpers

The scan package is optional. It executes Quarry queries with database/sql and scans results into structs or scalar types with predictable error handling.

Quarry logo

Execution helpers

scan.Build

Render SQL and args without executing anything.

scan.Exec

Run a built query through ExecContext.

scan.Query

Run a built query through QueryContext.

scan.One, MaybeOne, All

Scan one row, zero-or-one rows, or every row into Go values.

Result mapping

  • db tags win first, then json, then snake_case.
  • Unknown columns are ignored.
  • Pointer fields and sql.Null* types are supported.
  • Nil inputs and bad builder states return errors instead of panicking.
  • Pointer type parameters are rejected; use struct or scalar target types.
type User struct {
    ID        int            `db:"id"`
    Email     string         `db:"email"`
    CreatedAt time.Time      `db:"created_at"`
    Nickname  *string        `db:"nickname"`
}

Hydra stays external

Quarry keeps only the small scanning surface in-tree. For richer hydration workflows, use the standalone Hydra integration note and the external Hydra project.

Limitations

  • Scan is not an ORM. It does not load relationships or track entities.
  • Columns are matched by name, not by schema metadata.
  • Destination values must be pointers, scalars, or supported nullable types.