mysqldump

package module
v0.0.0-...-4368114 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

README

mysqldump

Go Reference

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Prettify = Transformers(func(s *SQL) error {
	q, err := sqlformat.Format(s.Query)
	if err != nil {
		return err
	}
	s.Query = q
	return nil
})

Functions

func CompareQuery

func CompareQuery(a, b string) (bool, error)

CompareQuery checks if two queries are equal.

func Dump

func Dump(t *testing.T, s *SQL, opts ...Option)

func Write

func Write(sql *SQL, transformers ...func(*SQL) error) ([]byte, error)

Types

type DB

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

func NewDBRecorder

func NewDBRecorder(db dbtx, rec recorder) *DB

func (*DB) Exec

func (d *DB) Exec(query string, args ...any) (sql.Result, error)

func (*DB) ExecContext

func (d *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*DB) Prepare

func (d *DB) Prepare(query string) (*sql.Stmt, error)

func (*DB) PrepareContext

func (d *DB) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (*DB) Query

func (d *DB) Query(query string, args ...any) (*sql.Rows, error)

func (*DB) QueryContext

func (d *DB) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

func (*DB) QueryRow

func (d *DB) QueryRow(query string, args ...any) *sql.Row

func (*DB) QueryRowContext

func (d *DB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

func (*DB) SetDB

func (d *DB) SetDB(db dbtx)

type Dumper

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

func New

func New(opts ...Option) *Dumper

func (*Dumper) Dump

func (d *Dumper) Dump(t *testing.T, s *SQL, opts ...Option)

type Option

type Option func(o *options)

func Colors

func Colors(colors bool) Option

func Env

func Env(env string) Option

func File

func File(file string) Option

func IgnoreArgs

func IgnoreArgs(args ...string) Option

func Transformers

func Transformers(ts ...func(*SQL) error) Option

type Recorder

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

Recorder logs the query and args.

func NewRecorder

func NewRecorder(t *testing.T, opts ...Option) *Recorder

NewRecorder ...

func (*Recorder) DB

func (r *Recorder) DB(db dbtx) dbtx

func (*Recorder) Record

func (r *Recorder) Record(method, query string, args ...any)

func (*Recorder) SetOptionsAt

func (r *Recorder) SetOptionsAt(id int, opts ...Option)

SetOptionsAt sets the options for the id-th call.

type SQL

type SQL struct {
	Query string
	Args  []any
}

func Read

func Read(b []byte) (*SQL, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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