Documentation
¶
Index ¶
- func IsWithinTransaction(ctx context.Context) bool
- func NestedTransactionsMSSQL(db sqlDB, tx *sql.Tx) (sqlDB, sqlTx)
- func NestedTransactionsNone(db sqlDB, tx *sql.Tx) (sqlDB, sqlTx)
- func NestedTransactionsOracle(db sqlDB, tx *sql.Tx) (sqlDB, sqlTx)
- func NestedTransactionsSavepoints(db sqlDB, tx *sql.Tx) (sqlDB, sqlTx)
- type DB
- type DBGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWithinTransaction ¶ added in v1.1.0
func NestedTransactionsMSSQL ¶
NestedTransactionsMSSQL is a nested transactions implementation using Microsoft SQL Server savepoints.
func NestedTransactionsNone ¶
NestedTransactionsNone is an implementation that prevents using nested transactions.
func NestedTransactionsOracle ¶
NestedTransactionsOracle is a nested transactions implementation using Oracle savepoints.
func NestedTransactionsSavepoints ¶
NestedTransactionsSavepoints is a nested transactions implementation using savepoints. It's compatible with PostgreSQL, MySQL, MariaDB, and SQLite.
Types ¶
type DB ¶
type DB interface {
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
Exec(query string, args ...any) (sql.Result, error)
Prepare(query string) (*sql.Stmt, error)
Query(query string, args ...any) (*sql.Rows, error)
QueryRow(query string, args ...any) *sql.Row
}
type DBGetter ¶
DBGetter is used to get the current DB handler from the context. It returns the current transaction if there is one, otherwise it will return the original DB.
func NewFakeTransactor ¶
func NewFakeTransactor(db *sql.DB) (transactor.Transactor, DBGetter)
NewFakeTransactor initializes a Transactor and DBGetter that do nothing: - the Transactor just executes its callback and returns the error, - the DBGetter just returns the DB handler. They can be used in tests where the transaction system itself doesn't need to be tested.
func NewTransactor ¶
func NewTransactor(db *sql.DB, nestedTransactionStrategy nestedTransactionsStrategy) (transactor.Transactor, DBGetter)