parser

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomOperatorHandler added in v1.0.1

type CustomOperatorHandler interface {
	ToSQL(operator string, args []interface{}) (string, error)
}

CustomOperatorHandler is an interface for custom operator implementations. This mirrors the public OperatorHandler interface.

type CustomOperatorLookup added in v1.0.1

type CustomOperatorLookup func(operatorName string) (CustomOperatorHandler, bool)

CustomOperatorLookup is a function type for looking up custom operators.

type Parser

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

Parser parses JSON Logic expressions and converts them to SQL WHERE clauses.

func NewParser

func NewParser(config *operators.OperatorConfig) *Parser

NewParser creates a new parser instance with config. Config must not be nil and must have a valid dialect set.

func (*Parser) Parse

func (p *Parser) Parse(logic interface{}) (string, error)

Parse converts a JSON Logic expression to SQL WHERE clause.

func (*Parser) ParseCondition added in v1.0.3

func (p *Parser) ParseCondition(logic interface{}) (string, error)

ParseCondition converts a JSON Logic expression to a SQL condition without the WHERE keyword. This is useful when you need to embed the condition in a larger query.

func (*Parser) SetCustomOperatorLookup added in v1.0.1

func (p *Parser) SetCustomOperatorLookup(lookup CustomOperatorLookup)

SetCustomOperatorLookup sets the function used to look up custom operators. This also sets up the validator to recognize custom operators.

func (*Parser) SetSchema added in v1.0.1

func (p *Parser) SetSchema(schema operators.SchemaProvider)

SetSchema sets the schema provider for field validation and type checking.

Jump to

Keyboard shortcuts

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