pgxcommon

package
v0.1.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pgxcommon provides Row, Rows, and Transaction wrappers shared by all pgx-based database dialect implementations (Postgres, Spanner via PGAdapter, …).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessModeToPgx

func AccessModeToPgx(accessMode database.AccessMode) pgx.TxAccessMode

AccessModeToPgx converts a database.AccessMode to its pgx equivalent.

func IsolationToPgx

func IsolationToPgx(isolation database.IsolationLevel) pgx.TxIsoLevel

IsolationToPgx converts a database.IsolationLevel to its pgx equivalent.

func TransactionOptionsToPgx

func TransactionOptionsToPgx(opts *database.TransactionOptions) pgx.TxOptions

TransactionOptionsToPgx converts database.TransactionOptions to pgx options.

Types

type Row

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

Row wraps pgx.Row and applies a dialect-specific error mapper.

func NewRow

func NewRow(row pgx.Row, wrapErr func(error) error) *Row

NewRow creates a Row that applies wrapErr to any scan error.

func (*Row) Scan

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

Scan implements database.Row.

type Rows

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

Rows wraps pgx.Rows and applies a dialect-specific error mapper.

func NewRows

func NewRows(rows pgx.Rows, wrapErr func(error) error) *Rows

NewRows creates a Rows that applies wrapErr to any error.

func (*Rows) Close

func (r *Rows) Close() error

Close implements database.Rows.

func (*Rows) Collect

func (r *Rows) Collect(dest any) (err error)

Collect implements database.CollectableRows.

func (*Rows) CollectExactlyOneRow

func (r *Rows) CollectExactlyOneRow(dest any) (err error)

CollectExactlyOneRow implements database.CollectableRows.

func (*Rows) CollectFirst

func (r *Rows) CollectFirst(dest any) (err error)

CollectFirst implements database.CollectableRows.

func (*Rows) Err

func (r *Rows) Err() error

Err implements database.Rows.

func (*Rows) Scan

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

Scan implements database.Rows.

type Transaction

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

Transaction wraps pgx.Tx and applies a dialect-specific error mapper.

func NewTransaction

func NewTransaction(tx pgx.Tx, wrapErr func(error) error) *Transaction

NewTransaction wraps tx, applying wrapErr to all errors.

func (*Transaction) Begin

Begin creates a savepoint to emulate nested transactions. opts is ignored because pgx savepoints do not accept per-nested-tx options.

func (*Transaction) Commit

func (tx *Transaction) Commit(ctx context.Context) error

func (*Transaction) End

func (tx *Transaction) End(ctx context.Context, err error) error

func (*Transaction) Exec

func (tx *Transaction) Exec(ctx context.Context, sql string, args ...any) (int64, error)

func (*Transaction) Query

func (tx *Transaction) Query(ctx context.Context, sql string, args ...any) (database.Rows, error)

func (*Transaction) QueryRow

func (tx *Transaction) QueryRow(ctx context.Context, sql string, args ...any) database.Row

func (*Transaction) Rollback

func (tx *Transaction) Rollback(ctx context.Context) error

Jump to

Keyboard shortcuts

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