* fix(metadata): allow / in metadata keys
ValidateMetadataKey rejected slashes even though keys are always passed
as bind parameters and JSONMetadataPath quotes non-identifier keys, so
the restriction had no safety purpose. Allow / in the key charset and
quote slash keys in JSON paths (unquoted, / is a path syntax error).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jrTawz2CRUiJLCt2UTQ2B
* fix(query): make slash metadata keys queryable; always quote JSON paths
Code-review follow-ups to the / metadata-key change:
- Allow / in query-language identifiers so keys like jira/sprint are
reachable from 'metadata.jira/sprint=42' expressions, not just the
--metadata-field flag.
- JSONMetadataPath now quotes every key unconditionally (valid for plain
keys too), removing the separator char list that had to stay in sync
with validMetadataKeyRe.
- Derive the ValidateMetadataKey error message from the regex itself.
- Collapse the five JSONMetadataPath clone tests into one table-driven
test.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jrTawz2CRUiJLCt2UTQ2B
* test(query): enforce that all valid metadata keys are queryable
Sweep every printable ASCII character and assert each key accepted by
storage.ValidateMetadataKey parses as metadata.<key>=<value>, so the
lexer's identifier alphabet and the storage key regex can't drift apart
and silently recreate the unqueryable-key bug class.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jrTawz2CRUiJLCt2UTQ2B
* fix(query): preserve metadata key case; escape JSON path keys
Review follow-ups on this branch:
- The parser lowercased the whole field token, so mixed-case metadata
keys (valid per ValidateMetadataKey, stored case-sensitively) were
silently unqueryable via metadata.<key>=<value> — and inconsistent
with has_metadata_key and the --metadata flag, which preserve case.
Keep field-name matching case-insensitive but restore the key
suffix's original case.
- JSONMetadataPath spliced the key into the quoted path unescaped,
relying on every caller validating first. Escape \ and " locally so
the function is correct for any input.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jrTawz2CRUiJLCt2UTQ2B
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
Support metadata existence checks in the query DSL:
bd query "has_metadata_key=team AND status=open"
Completes the list/search/query triangle for metadata existence
filtering. Uses existing IssueFilter.HasMetadataKey field and
SQL-level JSON_EXTRACT IS NOT NULL from PR2.
Implements GH#1406.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a new `bd query` command that enables complex filtering with a simple
query language supporting boolean operators, comparisons, and date-relative
expressions.
Features:
- Field comparisons: status=open, priority>1, updated>7d
- Boolean operators: AND, OR, NOT (case-insensitive)
- Parentheses for grouping: (status=open OR status=blocked) AND priority<2
- Date-relative expressions: 7d, 24h, 2w (interpreted as "X ago")
- Supports all IssueFilter fields: status, priority, type, assignee, label,
title, description, notes, created, updated, closed, id, spec, pinned,
ephemeral, template, parent, mol_type
Implementation:
- New internal/query package with lexer, parser, and evaluator
- Simple AND queries converted directly to IssueFilter for SQL efficiency
- Complex OR queries use predicate functions for in-memory filtering
- Comprehensive test coverage (62 tests)
Examples:
bd query "status=open AND priority>1"
bd query "(status=open OR status=blocked) AND updated>7d"
bd query "NOT status=closed AND type=bug"
bd query "label=urgent OR label=critical"
Closes: bd-o9g
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>