beads/internal/query
Rome Thorstenson 0121718514
fix(query): lex digit-led identifier-shaped tokens as identifiers (#4403)
The query lexer unconditionally dispatched digit-led tokens to the
number/duration reader, which only accepts digits followed by an optional
single-character duration suffix. Identifier-shaped values like
"1-alpha" or "42d-sla" tripped the reader at the first non-digit /
non-suffix byte:

    $ bd query 'assignee=1-alpha'
    Error: parsing query: expected digit at position 11

Every caller that wanted to filter on such a value had to quote it or
fall back to a client-side filter, which is silly given that the
character set is already accepted in the identifier reader. The query
DSL otherwise treats identifiers and values uniformly (cf. existing
"identifier with hyphen" / "unquoted identifier with colon" coverage),
so it is the digit-led case that is the outlier.

Two changes in readNumberOrDuration:

  - The duration suffix only fires when the suffix character stands
    alone (no further identifier-continuation lookahead). "7d" → still
    a duration; "7day" → falls through to identifier.
  - After reading the digit run, if an unsigned token butts against
    more identifier characters, the lex restarts at the start position
    and re-reads the token as an identifier. Signed forms ("-3-foo")
    still error so arithmetic-shaped input doesn't silently become an
    identifier.

Five lexer cases added covering both directions: digit-led identifiers
parse cleanly, durations still survive when the suffix is terminal.
2026-07-05 11:15:15 -07:00
..
evaluator.go feat(issues): add started_at timestamp (GH#2796) (#3206) 2026-04-14 09:24:08 -07:00
lexer.go fix(query): lex digit-led identifier-shaped tokens as identifiers (#4403) 2026-07-05 11:15:15 -07:00
parser.go feat: add has_metadata_key to bd query DSL 2026-02-24 12:43:06 -05:00
query_test.go fix(query): lex digit-led identifier-shaped tokens as identifiers (#4403) 2026-07-05 11:15:15 -07:00