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 ¶
- Variables
- func ChainErrorIfExecNotSatisfiedBy(err error, r Requirement, actual int64) error
- func ChainErrorIfQueryNotSatisfiedBy(err error, r Requirement, actual int64) error
- func ErrorIfExecNotSatisfiedBy(r Requirement, actual int64) error
- func ErrorIfQueryNotSatisfiedBy(r Requirement, actual int64) error
- type AtLeast
- type Exactly
- type LateBound
- type NoMoreThan
- type Quantifier
- type Requirement
Constants ¶
This section is empty.
Variables ¶
var AtLeastOne = AtLeast(1)
AtLeastOne is a requirement that is met by the actual results being at least one, i.e. not empty.
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 LateBound ¶
type LateBound uint
LateBound is a requirement that is updated to match exactly some number known at call time.
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.