filter

package
v0.18.4 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInternalError = errors.New("internal error")
View Source
var ErrUnknownFunction = errors.New("unknown function")
View Source
var ErrUnknownName = errors.New("unknown name")

Functions

func InternalError added in v0.18.0

func InternalError(err error) error

func UnknownFunction added in v0.18.0

func UnknownFunction(name string) error

func UnknownName added in v0.18.0

func UnknownName(name string) error

Types

type AndExpr

type AndExpr struct {
	Left  FilterExpr
	Right FilterExpr
}

type FilterExpr

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

type InTableExpr

type InTableExpr struct {
	Not   bool
	Table Table
	Ids   []string
}

type IsNullExpr added in v0.18.0

type IsNullExpr struct {
	Name string
	Not  bool
}

type Name

type Name struct {
	Kind     NameKind
	Name     string
	Nullable bool
}

type NameKind

type NameKind int
const (
	NameKindString NameKind = iota
	NameKindNumber
)

type OpExpr

type OpExpr struct {
	Kind  OpKind
	Name  string
	Value any
}

type OpKind

type OpKind int
const (
	OpEqual OpKind = iota
	OpNotEqual
	OpLike
	OpGreater
	OpGreaterEqual
	OpLesser
	OpLesserEqual
)

type OrExpr

type OrExpr struct {
	Left  FilterExpr
	Right FilterExpr
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func New

func New(adpater ResolverAdapter) *Resolver

func (*Resolver) InTable

func (r *Resolver) InTable(name, typ string, args []ast.Expr) (*InTableExpr, error)

func (*Resolver) Resolve

func (r *Resolver) Resolve(e ast.Expr) (FilterExpr, error)

func (*Resolver) ResolveSort added in v0.18.0

func (r *Resolver) ResolveSort(e SortExpr) (SortExpr, error)

func (*Resolver) ResolveToIdent

func (r *Resolver) ResolveToIdent(e ast.Expr) (string, error)

func (*Resolver) ResolveToNumber

func (r *Resolver) ResolveToNumber(e ast.Expr) (int64, error)

func (*Resolver) ResolveToStr

func (r *Resolver) ResolveToStr(e ast.Expr) (string, error)

type ResolverAdapter

type ResolverAdapter interface {
	ResolveNameToId(typ, name string) (string, bool)
	ResolveVariableName(name string) (Name, bool)
	ResolveTable(typ string) (Table, bool)

	ResolveFunctionCall(resolver *Resolver, name string, args []ast.Expr) (FilterExpr, error)

	DefaultSort() (string, SortType)
}

type SortExpr added in v0.18.0

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

func ParseSort added in v0.18.0

func ParseSort(s string) (SortExpr, error)

type SortExprDefault added in v0.18.0

type SortExprDefault struct{}

type SortExprRandom added in v0.18.0

type SortExprRandom struct{}

type SortExprSort added in v0.18.0

type SortExprSort struct {
	Items []SortItem
}

type SortItem added in v0.18.0

type SortItem struct {
	Type SortType
	Name string
}

type SortType added in v0.18.0

type SortType int
const (
	SortTypeAsc SortType = iota
	SortTypeDesc
)

type Table

type Table struct {
	Name       string
	SelectName string
	WhereName  string
}

Jump to

Keyboard shortcuts

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