sqlguard

package
v1.0.0-rc.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlguard adapts database/sql operations to operation.Engine. It does not install a driver, own the database, or enforce inside PostgreSQL itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB, engine *operation.Engine, metadata Metadata) (*DB, error)

func (*DB) BeginTx

func (d *DB) BeginTx(ctx context.Context, options *sql.TxOptions) (*Tx, error)

BeginTx owns cancellation cleanup. It acquires a connection with the caller context, then begins with a noncanceling control context so database/sql cannot mark a transaction done before an asynchronous driver rollback actually ends. Begin/Commit/Rollback driver control calls may wait for driver network timeouts; the permit remains held throughout. Queries use caller cancellation normally.

func (*DB) ExecContext

func (d *DB) ExecContext(ctx context.Context, query string, args ...any) (result sql.Result, err error)

func (*DB) InTx

func (d *DB) InTx(ctx context.Context, options *sql.TxOptions, fn func(*Tx) error) (err error)

InTx guarantees rollback on callback failure or panic, and commits only on a successful return. Use tx methods, not the outer DB wrapper, inside the body.

func (*DB) QueryContext

func (d *DB) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error)

QueryContext holds admission until Rows.Close or terminal iteration. Always defer Close. Abandoning rows without closing them retains the permit.

func (*DB) QueryRowContext

func (d *DB) QueryRowContext(ctx context.Context, query string, args ...any) *Row

type Metadata

type Metadata func(context.Context) operation.Request

type Row

type Row struct {
	// contains filtered or unexported fields
}

func (*Row) Scan

func (r *Row) Scan(dest ...any) error

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

func (*Rows) Close

func (r *Rows) Close() error

func (*Rows) Columns

func (r *Rows) Columns() ([]string, error)

func (*Rows) Err

func (r *Rows) Err() error

func (*Rows) Next

func (r *Rows) Next() bool

func (*Rows) NextResultSet

func (r *Rows) NextResultSet() bool

NextResultSet is explicit for multiple-result drivers; callers still close on exit.

func (*Rows) Scan

func (r *Rows) Scan(dest ...any) error

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Context

func (t *Tx) Context() context.Context

func (*Tx) ExecContext

func (t *Tx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*Tx) QueryContext

func (t *Tx) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error)

func (*Tx) QueryRowContext

func (t *Tx) QueryRowContext(ctx context.Context, query string, args ...any) *Row

func (*Tx) Rollback

func (t *Tx) Rollback() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL