sqlz

package
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sqlz contains core types such as Kind and Record.

Index

Constants

View Source
const (
	TableTypeTable = "table"
	TableTypeView  = "view"
)

Canonical driver-independent names for "table" and "view".

Variables

View Source
var (
	RTypeInt         = reflect.TypeOf(0)
	RTypeInt8        = reflect.TypeOf(int8(0))
	RTypeInt16       = reflect.TypeOf(int16(0))
	RTypeInt32       = reflect.TypeOf(int32(0))
	RTypeInt64       = reflect.TypeOf(int64(0))
	RTypeNullInt64   = reflect.TypeOf(sql.NullInt64{})
	RTypeFloat32     = reflect.TypeOf(float32(0))
	RTypeFloat64     = reflect.TypeOf(float64(0))
	RTypeNullFloat64 = reflect.TypeOf(sql.NullFloat64{})
	RTypeBool        = reflect.TypeOf(true)
	RTypeNullBool    = reflect.TypeOf(sql.NullBool{})
	RTypeString      = reflect.TypeOf("")
	RTypeNullString  = reflect.TypeOf(sql.NullString{})
	RTypeTime        = reflect.TypeOf(time.Time{})
	RTypeNullTime    = reflect.TypeOf(sql.NullTime{})
	RTypeBytes       = reflect.TypeOf([]byte{})
	RTypeNil         = reflect.TypeOf(nil)
	RTypeAny         = reflect.TypeOf((any)(nil))
)

Cached results from reflect.TypeOf for commonly used types.

Functions

func ExecAffected added in v0.15.0

func ExecAffected(ctx context.Context, db Execer, query string, args ...any) (affected int64, err error)

ExecAffected invokes db.ExecContext, returning the count of rows affected and any error.

Types

type DB

type DB interface {
	Execer
	Queryer
	Preparer
}

DB is a union of Execer, Queryer and Preparer. DB's method set is implemented by sql.DB, sql.Conn and sql.Tx. This can probably be better named, as it conflicts with sql.DB.

type Execer

type Execer interface {
	// ExecContext is documented by sql.DB.ExecContext.
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

Execer abstracts the ExecContext method from sql.DB and friends.

type NullBool

type NullBool struct {
	sql.NullBool
}

NullBool is similar to sql.NullBool, but accepts more boolean representations, e.g. "YES", "Y", "NO", "N", etc. These boolean values are returned by SQL Server and Postgres at times.

func (*NullBool) Scan

func (n *NullBool) Scan(value any) error

Scan implements the Scanner interface.

type Preparer

type Preparer interface {
	// PrepareContext is documented by sql.DB.PrepareContext.
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}

Preparer abstracts the PrepareContext method from sql.DB and friends.

type Queryer

type Queryer interface {
	// QueryContext is documented by sql.DB.QueryContext.
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

	// QueryRowContext is documented by sql.DB.QueryRowContext.
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

Queryer abstracts the QueryContext and QueryRowContext methods from sql.DB and friends.

Jump to

Keyboard shortcuts

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