predicate

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Code generated by mkunion. DO NOT EDIT.

Code generated by mkunion. DO NOT EDIT.

Code generated by mkunion. DO NOT EDIT.

Code generated by mkunion. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AndShape added in v1.21.0

func AndShape() shape.Shape

func AndToJSON added in v1.21.0

func AndToJSON(x *And) ([]byte, error)

func BindValueShape added in v1.21.0

func BindValueShape() shape.Shape

func BindValueToJSON added in v1.21.0

func BindValueToJSON(x *BindValue) ([]byte, error)

func BindableShape added in v1.21.0

func BindableShape() shape.Shape

func BindableToJSON added in v1.21.0

func BindableToJSON(x Bindable) ([]byte, error)

func CompareShape added in v1.21.0

func CompareShape() shape.Shape

func CompareToJSON added in v1.21.0

func CompareToJSON(x *Compare) ([]byte, error)

func Evaluate

func Evaluate[A any](predicate Predicate, data A, bind ParamBinds) bool

func EvaluateEqual

func EvaluateEqual[A any](data A, location string, value any) bool

func EvaluateEqualPrimitive added in v1.21.0

func EvaluateEqualPrimitive(record schema.Schema, location string, value any) bool

func EvaluateSchema added in v1.21.0

func EvaluateSchema(predicate Predicate, data schema.Schema, bind ParamBinds) bool

func EvaluateShape added in v1.21.0

func EvaluateShape(predicate Predicate, s shape.Shape, data schema.Schema, bind ParamBinds) bool

func GetValue

func GetValue(x Bindable, params ParamBinds, data schema.Schema) (schema.Schema, bool)

func LiteralShape added in v1.21.0

func LiteralShape() shape.Shape

func LiteralToJSON added in v1.21.0

func LiteralToJSON(x *Literal) ([]byte, error)

func LocatableShape added in v1.21.0

func LocatableShape() shape.Shape

func LocatableToJSON added in v1.21.0

func LocatableToJSON(x *Locatable) ([]byte, error)

func MatchBindable added in v1.21.0

func MatchBindable[TOut any](
	x Bindable,
	f1 func(x *BindValue) TOut,
	f2 func(x *Literal) TOut,
	f3 func(x *Locatable) TOut,
	df func(x Bindable) TOut,
) TOut

func MatchBindableR2 added in v1.21.0

func MatchBindableR2[TOut1, TOut2 any](
	x Bindable,
	f1 func(x *BindValue) (TOut1, TOut2),
	f2 func(x *Literal) (TOut1, TOut2),
	f3 func(x *Locatable) (TOut1, TOut2),
	df func(x Bindable) (TOut1, TOut2),
) (TOut1, TOut2)

func MatchPredicate added in v1.21.0

func MatchPredicate[TOut any](
	x Predicate,
	f1 func(x *And) TOut,
	f2 func(x *Or) TOut,
	f3 func(x *Not) TOut,
	f4 func(x *Compare) TOut,
	df func(x Predicate) TOut,
) TOut

func MatchPredicateR2 added in v1.21.0

func MatchPredicateR2[TOut1, TOut2 any](
	x Predicate,
	f1 func(x *And) (TOut1, TOut2),
	f2 func(x *Or) (TOut1, TOut2),
	f3 func(x *Not) (TOut1, TOut2),
	f4 func(x *Compare) (TOut1, TOut2),
	df func(x Predicate) (TOut1, TOut2),
) (TOut1, TOut2)

func MustMatchBindable added in v1.21.0

func MustMatchBindable[TOut any](
	x Bindable,
	f1 func(x *BindValue) TOut,
	f2 func(x *Literal) TOut,
	f3 func(x *Locatable) TOut,
) TOut

func MustMatchBindableR0 added in v1.21.0

func MustMatchBindableR0(
	x Bindable,
	f1 func(x *BindValue),
	f2 func(x *Literal),
	f3 func(x *Locatable),
)

func MustMatchBindableR2 added in v1.21.0

func MustMatchBindableR2[TOut1, TOut2 any](
	x Bindable,
	f1 func(x *BindValue) (TOut1, TOut2),
	f2 func(x *Literal) (TOut1, TOut2),
	f3 func(x *Locatable) (TOut1, TOut2),
) (TOut1, TOut2)

func MustMatchPredicate added in v1.21.0

func MustMatchPredicate[TOut any](
	x Predicate,
	f1 func(x *And) TOut,
	f2 func(x *Or) TOut,
	f3 func(x *Not) TOut,
	f4 func(x *Compare) TOut,
) TOut

func MustMatchPredicateR0 added in v1.21.0

func MustMatchPredicateR0(
	x Predicate,
	f1 func(x *And),
	f2 func(x *Or),
	f3 func(x *Not),
	f4 func(x *Compare),
)

func MustMatchPredicateR2 added in v1.21.0

func MustMatchPredicateR2[TOut1, TOut2 any](
	x Predicate,
	f1 func(x *And) (TOut1, TOut2),
	f2 func(x *Or) (TOut1, TOut2),
	f3 func(x *Not) (TOut1, TOut2),
	f4 func(x *Compare) (TOut1, TOut2),
) (TOut1, TOut2)

func NotShape added in v1.21.0

func NotShape() shape.Shape

func NotToJSON added in v1.21.0

func NotToJSON(x *Not) ([]byte, error)

func OrShape added in v1.21.0

func OrShape() shape.Shape

func OrToJSON added in v1.21.0

func OrToJSON(x *Or) ([]byte, error)

func ParamBindsShape added in v1.21.0

func ParamBindsShape() shape.Shape

func PredicateShape added in v1.21.0

func PredicateShape() shape.Shape

func PredicateToJSON added in v1.21.0

func PredicateToJSON(x Predicate) ([]byte, error)

func WherePredicatesShape added in v1.21.0

func WherePredicatesShape() shape.Shape

Types

type And

type And struct {
	L []Predicate
}

func AndFromJSON added in v1.21.0

func AndFromJSON(x []byte) (*And, error)

func (*And) AcceptPredicate added in v1.21.0

func (r *And) AcceptPredicate(v PredicateVisitor) any

func (*And) MarshalJSON added in v1.21.0

func (r *And) MarshalJSON() ([]byte, error)

func (*And) UnmarshalJSON added in v1.21.0

func (r *And) UnmarshalJSON(data []byte) error

type BindName

type BindName = string

type BindValue

type BindValue struct{ BindName BindName }

func BindValueFromJSON added in v1.21.0

func BindValueFromJSON(x []byte) (*BindValue, error)

func (*BindValue) AcceptBindable added in v1.21.0

func (r *BindValue) AcceptBindable(v BindableVisitor) any

func (*BindValue) MarshalJSON added in v1.21.0

func (r *BindValue) MarshalJSON() ([]byte, error)

func (*BindValue) UnmarshalJSON added in v1.21.0

func (r *BindValue) UnmarshalJSON(data []byte) error

type Bindable added in v1.21.0

type Bindable interface {
	AcceptBindable(g BindableVisitor) any
}

func BindableFromJSON added in v1.21.0

func BindableFromJSON(x []byte) (Bindable, error)

type BindableUnionJSON added in v1.21.0

type BindableUnionJSON struct {
	Type      string          `json:"$type,omitempty"`
	BindValue json.RawMessage `json:"predicate.BindValue,omitempty"`
	Literal   json.RawMessage `json:"predicate.Literal,omitempty"`
	Locatable json.RawMessage `json:"predicate.Locatable,omitempty"`
}

type BindableVisitor added in v1.21.0

type BindableVisitor interface {
	VisitBindValue(v *BindValue) any
	VisitLiteral(v *Literal) any
	VisitLocatable(v *Locatable) any
}

type Comparable

type Comparable struct {
	Location string `( @Location`
	Operator string `  @( "<>" | "<=" | ">=" | "=" | "<" | ">" | "!=" )`
	BindName Value  `  @@)`
}

func (Comparable) ToPredicate

func (a Comparable) ToPredicate() (Predicate, error)

type Compare

type Compare struct {
	Location  string
	Operation string
	BindValue Bindable
}

func CompareFromJSON added in v1.21.0

func CompareFromJSON(x []byte) (*Compare, error)

func (*Compare) AcceptPredicate added in v1.21.0

func (r *Compare) AcceptPredicate(v PredicateVisitor) any

func (*Compare) MarshalJSON added in v1.21.0

func (r *Compare) MarshalJSON() ([]byte, error)

func (*Compare) UnmarshalJSON added in v1.21.0

func (r *Compare) UnmarshalJSON(data []byte) error

type Condition

type Condition struct {
	Operand *Comparable `  @@`
	Not     *Condition  `| "NOT" @@`
}

func (*Condition) ToPredicate

func (c *Condition) ToPredicate() (Predicate, error)

type Expression

type Expression struct {
	Or []*OrCondition `@@ ( "OR" @@ )*`
}

func (Expression) ToPredicate

func (e Expression) ToPredicate() (Predicate, error)

type Literal

type Literal struct{ Value schema.Schema }

func LiteralFromJSON added in v1.21.0

func LiteralFromJSON(x []byte) (*Literal, error)

func (*Literal) AcceptBindable added in v1.21.0

func (r *Literal) AcceptBindable(v BindableVisitor) any

func (*Literal) MarshalJSON added in v1.21.0

func (r *Literal) MarshalJSON() ([]byte, error)

func (*Literal) UnmarshalJSON added in v1.21.0

func (r *Literal) UnmarshalJSON(data []byte) error

type Locatable

type Locatable struct{ Location string }

func LocatableFromJSON added in v1.21.0

func LocatableFromJSON(x []byte) (*Locatable, error)

func (*Locatable) AcceptBindable added in v1.21.0

func (r *Locatable) AcceptBindable(v BindableVisitor) any

func (*Locatable) MarshalJSON added in v1.21.0

func (r *Locatable) MarshalJSON() ([]byte, error)

func (*Locatable) UnmarshalJSON added in v1.21.0

func (r *Locatable) UnmarshalJSON(data []byte) error

type Not

type Not struct {
	P Predicate
}

func NotFromJSON added in v1.21.0

func NotFromJSON(x []byte) (*Not, error)

func (*Not) AcceptPredicate added in v1.21.0

func (r *Not) AcceptPredicate(v PredicateVisitor) any

func (*Not) MarshalJSON added in v1.21.0

func (r *Not) MarshalJSON() ([]byte, error)

func (*Not) UnmarshalJSON added in v1.21.0

func (r *Not) UnmarshalJSON(data []byte) error

type Or

type Or struct {
	L []Predicate
}

func OrFromJSON added in v1.21.0

func OrFromJSON(x []byte) (*Or, error)

func (*Or) AcceptPredicate added in v1.21.0

func (r *Or) AcceptPredicate(v PredicateVisitor) any

func (*Or) MarshalJSON added in v1.21.0

func (r *Or) MarshalJSON() ([]byte, error)

func (*Or) UnmarshalJSON added in v1.21.0

func (r *Or) UnmarshalJSON(data []byte) error

type OrCondition

type OrCondition struct {
	And []*Condition `@@ ( "AND" @@ )*`
}

func (*OrCondition) ToPredicate

func (c *OrCondition) ToPredicate() (Predicate, error)

type ParamBinds

type ParamBinds map[BindName]schema.Schema

func (*ParamBinds) MarshalJSON added in v1.20.2

func (r *ParamBinds) MarshalJSON() ([]byte, error)

func (*ParamBinds) UnmarshalJSON added in v1.20.2

func (r *ParamBinds) UnmarshalJSON(data []byte) error

type Predicate added in v1.21.0

type Predicate interface {
	AcceptPredicate(g PredicateVisitor) any
}

func Optimize added in v1.21.0

func Optimize(p Predicate) Predicate

func Parse added in v1.21.0

func Parse(input string) (Predicate, error)

func PredicateFromJSON added in v1.21.0

func PredicateFromJSON(x []byte) (Predicate, error)

type PredicateUnionJSON added in v1.21.0

type PredicateUnionJSON struct {
	Type    string          `json:"$type,omitempty"`
	And     json.RawMessage `json:"predicate.And,omitempty"`
	Or      json.RawMessage `json:"predicate.Or,omitempty"`
	Not     json.RawMessage `json:"predicate.Not,omitempty"`
	Compare json.RawMessage `json:"predicate.Compare,omitempty"`
}

type PredicateVisitor added in v1.21.0

type PredicateVisitor interface {
	VisitAnd(v *And) any
	VisitOr(v *Or) any
	VisitNot(v *Not) any
	VisitCompare(v *Compare) any
}

type Value

type Value struct {
	BindName *string  `(  @Bind`
	Number   *float64 `| @Number`
	String   *string  `| @String`
	Bool     *string  `| @("TRUE" | "FALSE" | "true" | "false") `
	Location *string  `| @Location )`
}

func (Value) ToBindable

func (v Value) ToBindable() Bindable

type WherePredicates

type WherePredicates struct {
	Predicate Predicate
	Params    ParamBinds
}

func MustWhere

func MustWhere(query string, params ParamBinds) *WherePredicates

func Where

func Where(query string, params ParamBinds) (*WherePredicates, error)

func (*WherePredicates) Evaluate

func (w *WherePredicates) Evaluate(data schema.Schema) bool

func (*WherePredicates) MarshalJSON added in v1.20.2

func (r *WherePredicates) MarshalJSON() ([]byte, error)

func (*WherePredicates) UnmarshalJSON added in v1.20.2

func (r *WherePredicates) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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