require

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: BSD-2-Clause Imports: 1 Imported by: 2

Documentation

Overview

Package require provides simple constraints to assist with detecting errors in database queries that arise from the wrong number of result (for example no result or too many results).

Index

Constants

This section is empty.

Variables

View Source
var AtLeastOne = AtLeast(1)

AtLeastOne is a requirement that is met by the actual results being at least one, i.e. not empty.

View Source
var NoMoreThanOne = NoMoreThan(1)

NoMoreThanOne is a requirement that is met by the actual results being no more than one.

Functions

func ChainErrorIfExecNotSatisfiedBy

func ChainErrorIfExecNotSatisfiedBy(err error, r Requirement, actual int64) error

ChainErrorIfExecNotSatisfiedBy matches a requirement against the actual result size for an exec query. The requirement may be nil in which case there will be no error. This function accepts an existing potential error, passig it on if not nil.

func ChainErrorIfQueryNotSatisfiedBy

func ChainErrorIfQueryNotSatisfiedBy(err error, r Requirement, actual int64) error

ChainErrorIfQueryNotSatisfiedBy matches a requirement against the actual result size for a select query. The requirement may be nil in which case there will be no error. This function accepts an existing potential error, passig it on if not nil.

func ErrorIfExecNotSatisfiedBy

func ErrorIfExecNotSatisfiedBy(r Requirement, actual int64) error

ErrorIfExecNotSatisfiedBy matches a requirement against the actual result size for an exec query. The requirement may be nil in which case there will be no error.

func ErrorIfQueryNotSatisfiedBy

func ErrorIfQueryNotSatisfiedBy(r Requirement, actual int64) error

ErrorIfQueryNotSatisfiedBy matches a requirement against the actual result size for a select query. The requirement may be nil in which case there will be no error.

Types

type AtLeast

type AtLeast uint

AtLeast is a requirement that is met by the actual results being at least a specified value.

type Exactly

type Exactly uint

Exactly is a requirement that is met by a number matching exactly.

type LateBound

type LateBound uint

LateBound is a requirement that is updated to match exactly some number known at call time.

const (
	All LateBound = iota
)

type NoMoreThan

type NoMoreThan uint

NoMoreThan is a requirement that is met by the actual results being no more than a specified value.

type Quantifier

type Quantifier uint

Quantifier is a requirement that is met by imprecise zero, singular or plural results. The value All will be automatically updated to match exactly some number known at call time.

const (
	None Quantifier = iota
	One
	Many
)

func (Quantifier) String

func (q Quantifier) String() string

type Requirement

type Requirement interface {
	// contains filtered or unexported methods
}

Requirement set an expectation on the outcome of a query.

Jump to

Keyboard shortcuts

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