Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arg ¶
type Arg struct {
Position int
Comparable *Comparable
Composite *Expression
}
type Comparable ¶
type Error ¶
type Error struct {
// Position is a 1-based byte offset into the filter.
Position int
Message string
}
Error carries the offset the filter failed at, which a caller reports back to whoever wrote the filter.
type Expression ¶
Expression is one or more sequences joined by AND, the loosest binding the grammar has.
func ParseExpression ¶
func ParseExpression(filter string) (*Expression, error)
ParseExpression reads a filter through the EBNF AIP-160 links at https://google.aip.dev/assets/misc/ebnf-filtering.txt and returns nil for the empty filter the grammar admits. It accepts every production, so a caller serving a subset rejects the rest against the tree rather than the text.
type Factor ¶
Factor is one or more terms joined by OR, which binds tighter than both AND and a sequence.
type Filtering ¶
type Filtering[T any] struct { // contains filtered or unexported fields }
Filtering holds the spec MustCompile checked. A value declared without it carries no spec, which Parse panics on rather than matching no column.
func MustCompile ¶
MustCompile returns what a filter is parsed through, and panics on a spec declared wrong, which no request can recover from and every request repeats.
type FunctionCompiler ¶
FunctionCompiler compiles the call a filter writes into the boolean predicate it stands for. Each argument arrives as the text the client wrote, and the compiler validates count and form. The SQL is parenthesised by the caller, so it may carry an OR.
type Predicate ¶
Predicate is the SQL a filter compiles to and the arguments it binds. Bind arguments are placed with ?, which a caller on a driver numbering them rebinds. Every chain of more than one part is parenthesised, so a caller joining the predicate with AND binds all of it.
type Restriction ¶
type Restriction struct {
Position int
Comparable *Comparable
Comparator string
Arg *Arg
}
Restriction compares a comparable against an argument. Comparator and Arg stay empty where the restriction names a comparable alone, which AIP-160 calls a global restriction.
type Simple ¶
type Simple struct {
Position int
Restriction *Restriction
Composite *Expression
}
type Spec ¶
type Spec[T any] struct { // Fields maps the name a client writes in filter to the column it matches. Fields map[string]queryfield.Field[T] // Functions maps the name a client calls in filter to what the call // compiles to. A call not named here is refused. Functions map[string]FunctionCompiler // LeadingWildcard takes a * opening a value, which matches on a suffix and // reads every row of the table, since no btree orders a string by its end. LeadingWildcard bool }