Versions in this module Expand all Collapse all v0 v0.1.0 Sep 9, 2022 Changes in this version + var ErrOperatingOnCompletedContext = fmt.Errorf("tried to operate on completed context") + func MaybeRollbackContext(context SqlContext) error + func WithSavepointContext(parent SqlContext, f func(*SavepointContext) (T, error)) (T, error) + func WithSubcontext(context SqlContext, f func(SqlContext) (T, error)) (T, error) + func WithTxContext(db *sql.DB, f func(*TxContext) (T, error)) (T, error) + type SavepointContext struct + func NewSavepointContext(parent SqlContext) (*SavepointContext, error) + func (c *SavepointContext) Commit() error + func (c *SavepointContext) Completed() bool + func (c *SavepointContext) Ctx() context.Context + func (c *SavepointContext) Exec(query string, args ...any) (sql.Result, error) + func (c *SavepointContext) Parent() SqlContext + func (c *SavepointContext) Prepare(query string) (*sql.Stmt, error) + func (c *SavepointContext) Query(query string, args ...any) (*sql.Rows, error) + func (c *SavepointContext) QueryRow(query string, args ...any) (*sql.Row, error) + func (c *SavepointContext) Rollback() error + func (c *SavepointContext) Stmt(stmt *sql.Stmt) (*sql.Stmt, error) + func (c *SavepointContext) Subcontext() (SqlContext, error) + func (c *SavepointContext) Tx() *sql.Tx + type SqlContext interface + Commit func() error + Completed func() bool + Ctx func() context.Context + Exec func(query string, args ...any) (sql.Result, error) + Prepare func(query string) (*sql.Stmt, error) + Query func(query string, args ...any) (*sql.Rows, error) + QueryRow func(query string, args ...any) (*sql.Row, error) + Rollback func() error + Stmt func(stmt *sql.Stmt) (*sql.Stmt, error) + Subcontext func() (SqlContext, error) + Tx func() *sql.Tx + type TxContext struct + func BeginTx(db *sql.DB) (*TxContext, error) + func NewContextFromTx(tx *sql.Tx) *TxContext + func NewContextFromTxAndCtx(tx *sql.Tx, ctx context.Context) *TxContext + func (c *TxContext) Commit() error + func (c *TxContext) Completed() bool + func (c *TxContext) Ctx() context.Context + func (c *TxContext) Exec(query string, args ...any) (sql.Result, error) + func (c *TxContext) Prepare(query string) (*sql.Stmt, error) + func (c *TxContext) Query(query string, args ...any) (*sql.Rows, error) + func (c *TxContext) QueryRow(query string, args ...any) (*sql.Row, error) + func (c *TxContext) Rollback() error + func (c *TxContext) Stmt(stmt *sql.Stmt) (*sql.Stmt, error) + func (c *TxContext) Subcontext() (SqlContext, error) + func (c *TxContext) Tx() *sql.Tx