transaction

package
v0.6.21 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package transaction provides mockable interfaces of sql package struct types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Exec(query string, args ...any) (sql.Result, error)
	Stmt(stmt *sql.Stmt) Stmt
}

Client is an interface over a subset of sql.Tx methods rationale 1: explicitly forbid direct access to Commit and Rollback functionality as that is exclusively dealt with by WithTransaction in ../db rationale 2: allow mocking

func NewClient

func NewClient(tx *sql.Tx) Client

type Stmt

type Stmt interface {
	Exec(args ...any) (sql.Result, error)
	Query(args ...any) (*sql.Rows, error)
	QueryContext(ctx context.Context, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, args ...any) *sql.Row
}

Stmt is an interface over a subset of sql.Stmt methods rationale: allow mocking

Jump to

Keyboard shortcuts

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