Help us shape the future of Go! Take the 2026 Go Developer Survey

sqltest

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SQL = sqlcode.MustInclude(
	sqlcode.Options{},
	sqlfs,
)

Functions

func DumpRows

func DumpRows(rows *sql.Rows)

func QueryDump

func QueryDump(dbi interface{}, qry string, args ...interface{})

Dump result of query to output

func QueryInt

func QueryInt(dbi CtxQuerier, qry string, args ...interface{}) (result int)

func QueryString

func QueryString(dbi CtxQuerier, qry string, args ...interface{}) (result string)

func QueryTime

func QueryTime(dbi CtxQuerier, qry string, args ...interface{}) (result time.Time)

Types

type CtxExecer

type CtxExecer interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

type CtxQuerier

type CtxQuerier interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

type Fixture

type Fixture struct {
	DB     *sql.DB
	DBName string

	Driver SqlDriverType
	// contains filtered or unexported fields
}

func NewFixture

func NewFixture() *Fixture

func (*Fixture) IsPostgresql

func (f *Fixture) IsPostgresql() bool

func (*Fixture) IsSqlServer

func (f *Fixture) IsSqlServer() bool

func (*Fixture) Quote

func (f *Fixture) Quote(value string) string

SQL specific quoting syntax

func (*Fixture) RunIfMssql

func (f *Fixture) RunIfMssql(t *testing.T, name string, fn func(t *testing.T))

func (*Fixture) RunMigrationFile

func (f *Fixture) RunMigrationFile(filename string)

func (*Fixture) Teardown

func (f *Fixture) Teardown()

type MapRow

type MapRow map[string]interface{}

type MapRows

type MapRows []MapRow

func QueryMaps

func QueryMaps(dbi CtxQuerier, qry string, args ...interface{}) MapRows

Returns the result of a query as a loosely typed structure, for use with test code

func RowsMap

func RowsMap(columns []string, rows Rows) (outRows MapRows)

type Row

type Row []interface{}

type Rows

type Rows []Row

func Query

func Query(dbi CtxQuerier, qry string, args ...interface{}) Rows

func RowIteratorToSlice

func RowIteratorToSlice(rows *sql.Rows) (columns []string, result Rows)

type SqlDriverType

type SqlDriverType int
const (
	SqlDriverMssql SqlDriverType = iota
	SqlDriverPgx
)

type StdoutLogger

type StdoutLogger struct {
}

func (StdoutLogger) Printf

func (s StdoutLogger) Printf(format string, v ...interface{})

func (StdoutLogger) Println

func (s StdoutLogger) Println(v ...interface{})

Jump to

Keyboard shortcuts

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