Documentation
¶
Index ¶
- func AppendConditions(ctx context.Context, engine *Engine, filters []string, dialect DialectName, ...) error
- type Column
- type ComparisonCondition
- type ComparisonOperator
- type ComprehensionKind
- type Condition
- type ConstantCondition
- type ContainsCondition
- type ContainsPredicate
- type DialectName
- type ElementInCondition
- type EndsWithPredicate
- type Engine
- type Field
- type FieldKind
- type FieldPredicateCondition
- type FieldRef
- type FieldType
- type FunctionValue
- type InCondition
- type ListComprehensionCondition
- type LiteralValue
- type LogicalCondition
- type LogicalOperator
- type NotCondition
- type PredicateExpr
- type Program
- type RenderOptions
- type Schema
- type StartsWithPredicate
- type Statement
- type ValueExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendConditions ¶
func AppendConditions(ctx context.Context, engine *Engine, filters []string, dialect DialectName, where *[]string, args *[]any) error
AppendConditions compiles the provided filters and appends the resulting SQL fragments and args.
Types ¶
type ComparisonCondition ¶
type ComparisonCondition struct {
Left ValueExpr
Right ValueExpr
Operator ComparisonOperator
}
ComparisonCondition represents a binary comparison.
type ComparisonOperator ¶
type ComparisonOperator string
ComparisonOperator lists supported comparison operators.
const ( CompareEq ComparisonOperator = "=" CompareNeq ComparisonOperator = "!=" CompareLt ComparisonOperator = "<" CompareLte ComparisonOperator = "<=" CompareGt ComparisonOperator = ">" CompareGte ComparisonOperator = ">=" )
type ComprehensionKind ¶
type ComprehensionKind string
ComprehensionKind enumerates the types of list comprehensions.
const (
ComprehensionExists ComprehensionKind = "exists"
)
type Condition ¶
type Condition interface {
// contains filtered or unexported methods
}
Condition represents a boolean expression derived from the CEL filter.
type ConstantCondition ¶
type ConstantCondition struct {
Value bool
}
ConstantCondition captures a literal boolean outcome.
type ContainsCondition ¶
ContainsCondition models the <field>.contains(<value>) call.
type ContainsPredicate ¶
type ContainsPredicate struct {
Substring string
}
ContainsPredicate represents t.contains("substring").
type DialectName ¶
type DialectName string
DialectName enumerates supported SQL dialects.
const ( DialectSQLite DialectName = "sqlite" DialectPostgres DialectName = "postgres" )
type ElementInCondition ¶
ElementInCondition represents the CEL syntax `"value" in field`.
type EndsWithPredicate ¶
type EndsWithPredicate struct {
Suffix string
}
EndsWithPredicate represents t.endsWith("suffix").
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine parses CEL filters into a dialect-agnostic condition tree.
func DefaultAttachmentEngine ¶
DefaultAttachmentEngine returns the process-wide attachment filter engine.
func DefaultEngine ¶
DefaultEngine returns the process-wide memo filter engine.
func (*Engine) CompileToStatement ¶
func (e *Engine) CompileToStatement(ctx context.Context, filter string, opts RenderOptions) (Statement, error)
CompileToStatement compiles and renders the filter in a single step.
type Field ¶
type Field struct {
Expressions map[DialectName]string
AllowedComparisonOps map[ComparisonOperator]bool
Column Column
Name string
Kind FieldKind
Type FieldType
AliasFor string
JSONPath []string
SupportsContains bool
}
Field captures the schema metadata for an exposed CEL identifier.
type FieldPredicateCondition ¶
type FieldPredicateCondition struct {
Field string
}
FieldPredicateCondition asserts that a field evaluates to true.
type FunctionValue ¶
FunctionValue captures simple function calls like size(tags).
type InCondition ¶
InCondition represents an IN predicate with literal list values.
type ListComprehensionCondition ¶
type ListComprehensionCondition struct {
Predicate PredicateExpr
Kind ComprehensionKind
Field string
IterVar string
}
ListComprehensionCondition represents CEL macros like exists(), all(), filter().
type LiteralValue ¶
type LiteralValue struct {
Value interface{}
}
LiteralValue holds a literal scalar.
type LogicalCondition ¶
type LogicalCondition struct {
Left Condition
Right Condition
Operator LogicalOperator
}
LogicalCondition composes two conditions with a logical operator.
type LogicalOperator ¶
type LogicalOperator string
LogicalOperator enumerates the supported logical operators.
const ( LogicalAnd LogicalOperator = "AND" LogicalOr LogicalOperator = "OR" )
type NotCondition ¶
type NotCondition struct {
Expr Condition
}
NotCondition negates a child condition.
type PredicateExpr ¶
type PredicateExpr interface {
// contains filtered or unexported methods
}
PredicateExpr represents predicates used in comprehensions.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program stores a compiled filter condition.
func (*Program) ConditionTree ¶
ConditionTree exposes the underlying condition tree.
type RenderOptions ¶
type RenderOptions struct {
Dialect DialectName
PlaceholderOffset int
DisableNullChecks bool
}
RenderOptions configure SQL rendering.
type Schema ¶
Schema collects CEL environment options and field metadata.
func NewAttachmentSchema ¶
func NewAttachmentSchema() Schema
NewAttachmentSchema constructs the attachment filter schema and CEL environment.
func NewSchema ¶
func NewSchema() Schema
NewSchema constructs the memo filter schema and CEL environment.
type StartsWithPredicate ¶
type StartsWithPredicate struct {
Prefix string
}
StartsWithPredicate represents t.startsWith("prefix").