hobbled

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package hobbled allows creation of hobbled or deficient database types to facilitate testing within sqlh.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WithoutBegin

type WithoutBegin interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

WithoutBegin has no Begin call.

func NewWithoutBegin

func NewWithoutBegin(db interface{}) WithoutBegin

NewWithoutBegin returns a WithoutBegin type.

type WithoutBeginWithoutPrepare

type WithoutBeginWithoutPrepare interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

WithoutBeginWithoutPrepare has no Begin or Prepare calls.

func NewWithoutBeginWithoutPrepare

func NewWithoutBeginWithoutPrepare(db interface{}) WithoutBeginWithoutPrepare

NewWithoutBeginWithoutPrepare returns a WithoutBeginWithoutPrepare type.

type WithoutPrepare

type WithoutPrepare interface {
	Begin() (*sql.Tx, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

WithoutPrepare has no Prepare calls.

func NewWithoutPrepare

func NewWithoutPrepare(db interface{}) WithoutPrepare

NewWithoutPrepare returns a WithoutPrepare type.

type Wrapper

type Wrapper int

Wrapper is a type that wraps around a DB in order to hobble it.

const (
	// Passthru does not modify database types given to it.
	Passthru Wrapper = iota
	// NoBegin removes Begin() from database types given to it.
	NoBegin
	// NoBeginNoPrepare removes Begin() and Prepare() from types given to it.
	NoBeginNoPrepare
)

func (Wrapper) String

func (me Wrapper) String() string

String describes the wrapper type.

func (Wrapper) WrapDB

func (me Wrapper) WrapDB(db *sql.DB) sqlh.IQueries

WrapDB wraps the given DB and returns a sqlh.IQueries instance.

Jump to

Keyboard shortcuts

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