expr

package
v0.0.0-...-3a32fef Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperatorEquals        = "=="
	OperatorNotEquals     = "!="
	OperatorGreater       = ">"
	OperatorGreaterEquals = ">="
	OperatorLess          = "<"
	OperatorLessEquals    = "<="
	OperatorIn            = "in"
	OperatorStartsWith    = "startsWith"
	OperatorEndsWith      = "endsWith"
	OperatorContains      = "contains"
)

Variables

This section is empty.

Functions

func SQL

func SQL(expr *Expr) (string, []interface{}, error)

SQL returns a database friendly format composed by a string clause and a slice of args

func StandardDeclarations

func StandardDeclarations() []*exprpb.Decl

StandardDeclarations returns a set of standard declarations to use within out parser

Types

type AndExpr

type AndExpr struct {
	Left  Node
	Right Node
}

AndExpr represents an AND expression node.

type Expr

type Expr struct {
	Root Node
}

Expr is the abstract representation of a previously filtered, parsed and checked expression.

func (*Expr) IsZero

func (e *Expr) IsZero() bool

IsZero returns true if the expression was neither created or initialized.

type Field

type Field struct {
	Name  string
	Ftype FieldType
}

Field represents a field with its name and type.

type FieldType

type FieldType byte

FieldType defines a field type.

const (
	BoolFieldType FieldType = iota
	IntegerFieldType
	DoubleFieldType
	StringFieldType
	BytesFieldType
	TimestampFieldType
	StringArrayFieldType
)

Field type values

type Node

type Node interface {
}

Node defines a node in a abstract syntax tree.

type NotExpr

type NotExpr struct {
	Not Node
}

NotExpr represents a NOT expression node.

type OpExpr

type OpExpr struct {
	Field *Field
	Op    string
	Args  []interface{}
}

OpExpr represents an operation expression node.

type OrExpr

type OrExpr struct {
	Left  Node
	Right Node
}

OrExpr represents an OR expression node.

type Parser

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

Parser is our expr parser

func NewParser

func NewParser(allowedFields map[string]*exprpb.Type, opts ...ParserOpt) (*Parser, error)

NewParser creates a new parser

func (*Parser) Parse

func (p *Parser) Parse(filter string) (*Expr, error)

Parse produces a database friendly expr from a cel string expr

type ParserOpt

type ParserOpt func(parser *Parser)

ParserOpt sets options such as validators.

func WithDeclarations

func WithDeclarations(declarations []*exprpb.Decl) ParserOpt

WithDeclarations overrides default declarations

type PresentExpr

type PresentExpr struct {
	Field *Field
}

PresentExpr represents a presence expression node.

Jump to

Keyboard shortcuts

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