where

package
v0.0.0-...-86b9d59 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WherePart

func WherePart(col string, set *ValueSet) string

WherePart returns the part of the where clause between parens, as in: (

	   geography_code IN ( ... )
    OR
    geography_code BETWEEN (low, high)
	   ...

)

col is the name of the column we are matching (eg, "geography_code" or "category_code"). set is a ValueSet which contains the single value and ranges returned by ParseMultiArgs.

If set has no single values or ranges, an empty string will be returned.

Types

type Callback

type Callback func(single, low, high *string) (s *string, l *string, h *string, e error)

When operating on a Single, the value of s on return can be:

nil - delete this Single
ptr to a new value - changes this Single
ptr to the current value - does not change this Single

Similarly when operating on a Range, the value of l and h on return can be:

nil - delete this Range
ptrs to new values - change this Range
ptrs to current values - does not change this Range

See the example changeCallback in where_test.go.

type ValueRange

type ValueRange struct {
	Low  string
	High string
}

ValueRange holds the low and high values for a range.

type ValueSet

type ValueSet struct {
	Singles []string      // list of single values; becomes IN
	Ranges  []*ValueRange // list of value ranges; becomes BETWEEN
}

ValueSet holds all the single values and ranges for a for a multi-valued query parameter.

func NewValueSet

func NewValueSet() *ValueSet

func ParseMultiArgs

func ParseMultiArgs(args []string) (*ValueSet, error)

ParseMultiArgs generates a ValueSet from multi value query parameters.

XXX return proper error types once errors are factored out of geodata

func (*ValueSet) AddRange

func (set *ValueSet) AddRange(low, high string)

func (*ValueSet) AddSingle

func (set *ValueSet) AddSingle(s string)

func (*ValueSet) Walk

func (set *ValueSet) Walk(callback Callback) (*ValueSet, error)

Walk calls the callback function for every Single and Range in set. The callback function can return values telling Walk to delete, change, or leave the value untouched. If the callback function returns an error, Walk will stop and return the error, returning a nil ValueSet. The original ValueSet will not be changed on error.

Jump to

Keyboard shortcuts

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