Documentation
¶
Overview ¶
Package txutil provides shared transaction helpers for store sub-packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LikeEscaper = strings.NewReplacer(`\`, `\\`, "%", `\%`, "_", `\_`)
LikeEscaper escapes SQL LIKE wildcards (% and _) and the escape character itself (\) in user-provided prefixes.
Functions ¶
func AppendPrefixFilter ¶
AppendPrefixFilter adds a LIKE clause for the given column if prefix is non-empty.
func DeferRollback ¶
func DeferRollback(tx Rollbacker)
DeferRollback is a deferred rollback helper that suppresses the expected sql.ErrTxDone error (which occurs after a successful Commit). Use as:
defer txutil.DeferRollback(tx)
Types ¶
type Rollbacker ¶
type Rollbacker interface {
Rollback() error
}
Rollbacker is any type that supports Rollback (e.g. *sql.Tx or test fakes).
type TableScanner ¶
type TableScanner[T any] struct { Scan func(row interface{ Scan(...any) error }) (*T, error) ScanInto func(row interface{ Scan(...any) error }, dst *T) error Columns string }
TableScanner co-locates a column list with its scan function, making it impossible to use mismatched column/scan pairs in queries.
Click to show internal directories.
Click to hide internal directories.