Quarry Docs
GitHub
Reference

Scanning Helpers

The scan package executes Quarry queries with database/sql and hydrates 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

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

Hydration behavior

  • 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.
type User struct {
    ID        int            `db:"id"`
    Email     string         `db:"email"`
    CreatedAt time.Time      `db:"created_at"`
    Nickname  *string        `db:"nickname"`
}

Hydra compatibility

The hydra package remains a thin wrapper over scan so projects can keep a familiar import path without pulling scanning logic into the core package.