Versions in this module Expand all Collapse all v0 v0.42.5 Jan 27, 2026 v0.42.4 Jan 27, 2026 Changes in this version + var ErrBadArgType = errors.New(...) + var ErrHookableTypeMismatch = errors.New(...) + var ErrNoNamedArgs = errors.New("Dialect does not support named arguments") + var ErrTooManyNamedArgs = errors.New("too many named args for single arg binder") + func All[T any](ctx context.Context, exec Executor, q Query, m scan.Mapper[T]) ([]T, error) + func Allx[Tr Transformer[T, V], T, V any](ctx context.Context, exec Executor, q Query, m scan.Mapper[T]) (V, error) + func Build(ctx context.Context, q Query) (string, []any, error) + func BuildN(ctx context.Context, q Query, start int) (string, []any, error) + func Cursor[T any](ctx context.Context, exec Executor, q Query, m scan.Mapper[T]) (scan.ICursor[T], error) + func Each[T any](ctx context.Context, exec Executor, q Query, m scan.Mapper[T]) (func(func(T, error) bool), error) + func Exec(ctx context.Context, exec Executor, q Query) (sql.Result, error) + func Express(ctx context.Context, w io.StringWriter, d Dialect, start int, e any) ([]any, error) + func ExpressIf(ctx context.Context, w io.StringWriter, d Dialect, start int, e any, cond bool, ...) ([]any, error) + func ExpressSlice[T any](ctx context.Context, w io.StringWriter, d Dialect, start int, expressions []T, ...) ([]any, error) + func MustBuild(ctx context.Context, q Query) (string, []any) + func MustBuildN(ctx context.Context, q Query, start int) (string, []any) + func One[T any](ctx context.Context, exec Executor, q Query, m scan.Mapper[T]) (T, error) + func SkipHooks(ctx context.Context) context.Context + func SkipModelHooks(ctx context.Context) context.Context + func SkipQueryHooks(ctx context.Context) context.Context + type BaseQuery struct + Dialect Dialect + Expression E + QueryType QueryType + func Cache(ctx context.Context, exec Executor, q Query) (BaseQuery[*cached], error) + func CacheN(ctx context.Context, exec Executor, q Query, start int) (BaseQuery[*cached], error) + func (b BaseQuery[E]) Apply(mods ...Mod[E]) + func (b BaseQuery[E]) Clone() BaseQuery[E] + func (b BaseQuery[E]) Exec(ctx context.Context, exec Executor) (sql.Result, error) + func (b BaseQuery[E]) GetLoaders() []Loader + func (b BaseQuery[E]) GetMapperMods() []scan.MapperMod + func (b BaseQuery[E]) RunHooks(ctx context.Context, exec Executor) (context.Context, error) + func (b BaseQuery[E]) Type() QueryType + func (b BaseQuery[E]) WriteQuery(ctx context.Context, w io.StringWriter, start int) ([]any, error) + func (b BaseQuery[E]) WriteSQL(ctx context.Context, w io.StringWriter, d Dialect, start int) ([]any, error) + func (q BaseQuery[E]) Build(ctx context.Context) (string, []any, error) + func (q BaseQuery[E]) BuildN(ctx context.Context, start int) (string, []any, error) + func (q BaseQuery[E]) Cache(ctx context.Context, exec Executor) (BaseQuery[*cached], error) + func (q BaseQuery[E]) CacheN(ctx context.Context, exec Executor, start int) (BaseQuery[*cached], error) + func (q BaseQuery[E]) MustBuild(ctx context.Context) (string, []any) + func (q BaseQuery[E]) MustBuildN(ctx context.Context, start int) (string, []any) + type BoundQuery struct + func BindNamed[Arg any](ctx context.Context, q Query, args Arg) BoundQuery[Arg] + func (b BoundQuery[Arg]) WriteQuery(ctx context.Context, w io.StringWriter, start int) ([]any, error) + func (b BoundQuery[E]) Exec(ctx context.Context, exec Executor) (sql.Result, error) + func (b BoundQuery[E]) GetLoaders() []Loader + func (b BoundQuery[E]) GetMapperMods() []scan.MapperMod + func (b BoundQuery[E]) RunHooks(ctx context.Context, exec Executor) (context.Context, error) + func (b BoundQuery[E]) WriteSQL(ctx context.Context, w io.StringWriter, d Dialect, start int) ([]any, error) + type Conn struct + func NewConn(conn *sql.Conn) Conn + func (d Conn) Begin(ctx context.Context) (Tx, error) + func (d Conn) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error) + func (d Conn) PrepareContext(ctx context.Context, query string) (StdPrepared, error) + func (d Conn) QueryContext(ctx context.Context, query string, args ...any) (scan.Rows, error) + type ContextualMod interface + Apply func(context.Context, T) (context.Context, error) + type ContextualModFunc func(context.Context, T) (context.Context, error) + func (c ContextualModFunc[T]) Apply(ctx context.Context, o T) (context.Context, error) + type ContextualModdable struct + Mods []ContextualMod[T] + func (h *ContextualModdable[T]) AppendContextualMod(mods ...ContextualMod[T]) + func (h *ContextualModdable[T]) AppendContextualModFunc(f func(context.Context, T) (context.Context, error)) + func (h *ContextualModdable[T]) RunContextualMods(ctx context.Context, o T) (context.Context, error) + type DB struct + func NewDB(db *sql.DB) DB + func Open(driverName, dataSource string) (DB, error) + func OpenDB(c driver.Connector) DB + func (d DB) Begin(ctx context.Context) (Tx, error) + func (d DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error) + func (d DB) PrepareContext(ctx context.Context, query string) (StdPrepared, error) + func (d DB) QueryContext(ctx context.Context, query string, args ...any) (scan.Rows, error) + func (d DB) RunInTx(ctx context.Context, txOptions *sql.TxOptions, ...) error + type DebugPrinter interface + PrintQuery func(query string, args ...any) + type Dialect interface + WriteArg func(w io.StringWriter, position int) + WriteQuoted func(w io.StringWriter, s string) + type DialectWithNamed interface + WriteNamedArg func(w io.StringWriter, name string) + type EmbeddedHook struct + Hooks []func(context.Context, Executor) (context.Context, error) + func (h *EmbeddedHook) AppendHooks(hooks ...func(context.Context, Executor) (context.Context, error)) + func (h *EmbeddedHook) RunHooks(ctx context.Context, exec Executor) (context.Context, error) + func (h *EmbeddedHook) SetHooks(hooks ...func(context.Context, Executor) (context.Context, error)) + type Executor interface + ExecContext func(context.Context, string, ...any) (sql.Result, error) + func Debug(exec Executor) Executor + func DebugToPrinter(exec Executor, w DebugPrinter) Executor + func DebugToWriter(exec Executor, w io.StringWriter) Executor + type Expression interface + WriteSQL func(ctx context.Context, w io.StringWriter, d Dialect, start int) (args []any, err error) + func Named(names ...string) Expression + func NamedGroup(names ...string) Expression + type ExpressionFunc func(ctx context.Context, w io.StringWriter, d Dialect, start int) ([]any, error) + func (e ExpressionFunc) WriteSQL(ctx context.Context, w io.StringWriter, d Dialect, start int) ([]any, error) + type Hook func(context.Context, Executor, T) (context.Context, error) + type HookableQuery interface + RunHooks func(context.Context, Executor) (context.Context, error) + type HookableType interface + AfterQueryHook func(context.Context, Executor, QueryType) error + type Hooks struct + func (h *Hooks[T, K]) AppendHooks(hooks ...Hook[T]) + func (h *Hooks[T, K]) GetHooks() []Hook[T] + func (h *Hooks[T, K]) RunHooks(ctx context.Context, exec Executor, o T) (context.Context, error) + type Load struct + func (l *Load) AppendLoader(f ...Loader) + func (l *Load) AppendMapperMod(f scan.MapperMod) + func (l *Load) GetLoaders() []Loader + func (l *Load) GetMapperMods() []scan.MapperMod + func (l *Load) SetLoaders(loaders ...Loader) + func (l *Load) SetMapperMods(mods ...scan.MapperMod) + type Loadable interface + GetLoaders func() []Loader + type Loader interface + Load func(ctx context.Context, exec Executor, retrieved any) error + type LoaderFunc func(ctx context.Context, exec Executor, retrieved any) error + func (l LoaderFunc) Load(ctx context.Context, exec Executor, retrieved any) error + type MapperModder interface + GetMapperMods func() []scan.MapperMod + type MissingArgError struct + Name string + func (e MissingArgError) Error() string + type Mod interface + Apply func(T) + type ModFunc func(T) + func (m ModFunc[T]) Apply(query T) + type Mods []Mod[T] + func ToMods[T Mod[Q], Q any](r ...T) Mods[Q] + func (m Mods[T]) Apply(query T) + type PreparedExecutor interface + Close func() error + ExecContext func(ctx context.Context, args ...any) (sql.Result, error) + QueryContext func(ctx context.Context, args ...any) (scan.Rows, error) + type Preparer interface + PrepareContext func(ctx context.Context, query string) (P, error) + type Query interface + Type func() QueryType + WriteQuery func(ctx context.Context, w io.StringWriter, start int) (args []any, err error) + type QueryStmt struct + func PrepareQuery[Arg any, P PreparedExecutor, T any](ctx context.Context, exec Preparer[P], q Query, m scan.Mapper[T]) (QueryStmt[Arg, T, []T], error) + func PrepareQueryx[Arg any, P PreparedExecutor, T any, Ts ~[]T](ctx context.Context, exec Preparer[P], q Query, m scan.Mapper[T]) (QueryStmt[Arg, T, Ts], error) + func (s QueryStmt[Arg, T, Ts]) All(ctx context.Context, arg Arg) (Ts, error) + func (s QueryStmt[Arg, T, Ts]) Cursor(ctx context.Context, arg Arg) (scan.ICursor[T], error) + func (s QueryStmt[Arg, T, Ts]) One(ctx context.Context, arg Arg) (T, error) + type QueryType int + const QueryTypeDelete + const QueryTypeInsert + const QueryTypeSelect + const QueryTypeUnknown + const QueryTypeUpdate + const QueryTypeValues + func (q QueryType) String() string + type RawNamedArgError struct + Name string + func (e RawNamedArgError) Error() string + type SkipContextualModsKey struct + type SkipModelHooksKey struct + type SkipQueryHooksKey struct + type SliceTransformer struct + func (SliceTransformer[T, Ts]) TransformScanned(scanned []T) (Ts, error) + type StdPrepared struct + func (s StdPrepared) QueryContext(ctx context.Context, args ...any) (scan.Rows, error) + type Stmt struct + func InTx[Arg any, S PreparedExecutor](ctx context.Context, s Stmt[Arg], tx txForStmt[S]) Stmt[Arg] + func Prepare[Arg any, P PreparedExecutor](ctx context.Context, exec Preparer[P], q Query) (Stmt[Arg], error) + func (s Stmt[Arg]) Close() error + func (s Stmt[Arg]) Exec(ctx context.Context, arg Arg) (sql.Result, error) + func (s Stmt[Arg]) NamedArgs() []string + type Transaction interface + Commit func(context.Context) error + Rollback func(context.Context) error + type Transactor interface + Begin func(context.Context) (Tx, error) + type Transformer interface + TransformScanned func([]T) (V, error) + type Tx struct + func NewTx(tx *sql.Tx) Tx + func (t Tx) Commit(_ context.Context) error + func (t Tx) PrepareContext(ctx context.Context, query string) (StdPrepared, error) + func (t Tx) QueryContext(ctx context.Context, query string, args ...any) (scan.Rows, error) + func (t Tx) Rollback(_ context.Context) error + func (tx Tx) StmtContext(ctx context.Context, stmt StdPrepared) StdPrepared + type WrongStartError struct + Expected int + Got int + func (e WrongStartError) Error() string