feat: configurable operators/directions, dotted fields, and docs restructure#11
Merged
Merged
Conversation
…ructure Add caller-side control over which filter operators and sort directions are accepted, support nested dot-notation field names, and reorganize the documentation into a docs/ folder. Configurable operators (opt-in; default allows everything): - New Operator enum (per-verb) and OperatorGroup presets, with AllOperators() and OperatorGroup.Operators() helpers. - NewFilterParser now takes variadic FilterOption; WithAllowedOperators and WithAllowedOperatorGroups (additive) restrict the grammar. Disallowed verbs produce `operator "X" is not allowed`, collected in the same single-pass aggregation. Negated predicates (NOT IN, NOT LIKE, ...) are governed by their base operator; OpNot governs only the standalone leading NOT. Configurable sort directions: - NewSortParser takes variadic SortOption; WithAllowedDirections(SortAsc/SortDesc) restricts directions (default allows both). Nested dot-notation fields: - Lexer sets scanner.IsIdentRune so "q.v.last_name" scans as a single identifier; a dot is valid only in interior positions, so numeric literals like 3.14 are unaffected. FieldsParser/SortParser already matched dotted names via string comparison; this brings FilterParser in line. Unknown dotted fields are rejected by the allow-list as usual. Constructor signatures are source-compatible (existing calls compile unchanged). Docs: - Move the detailed guides into docs/ (getting-started, filtering, configuration, error-handling, migration) with an index at docs/README.md. - Slim the top-level README to essentials: install/update, a quick-start example, a short feature list, and links into docs/. - Add godoc examples for WithAllowedOperatorGroups, WithAllowedDirections, and dotted fields. Tests: - Add operator-gating, group-coverage, sort-direction, and dotted-identifier tests. go vet, gofmt, and go test -race all pass; coverage 96.6%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three related additions, all backward compatible, plus a documentation restructure.
1. Configurable filter operators (opt-in)
Callers can restrict which operators a
FilterParseraccepts; the default (no option) still allows everything.Operatorenum (per-verb) +OperatorGrouppresets (GroupComparison,GroupPattern,GroupLogical, …), both additive.AllOperators()andOperatorGroup.Operators().NOT IN,NOT LIKE,IS NOT DISTINCT FROM, …) are governed by their base operator;OpNotgoverns only the standalone leadingNOT (…).2. Configurable sort directions (opt-in)
3. Nested dot-notation field names
FilterParsernow accepts dotted identifiers viascanner.IsIdentRune:A dot is valid only inside an identifier, so numeric literals (
3.14) are unaffected.FieldsParser/SortParseralready matched dotted names (plain string comparison); this bringsFilterParserin line. Unknown dotted fields are rejected by the allow-list as usual.Constructors stay source-compatible —
NewFilterParser(fields)/NewSortParser(fields)gained variadic options, so existing calls compile unchanged.Documentation restructure
docs/: getting-started, filtering, configuration, error-handling, migration.README.mdslimmed to essentials — install/update, a quick-start, a short feature list, and links intodocs/.Example*functions for the new options and dotted fields.Tests
go vet,gofmt,go test -race ./...all pass; coverage 96.6%.All of this targets the same unreleased v0.1.0 line; the migration guide (
docs/migration.md) documents it as additive items 7–8.