feat: add OR-condition support for search/filter syntax#38
Merged
Conversation
Implement shared-prefix OR query expansion across github-projects-client and github-project-export. Each OR branch becomes a separate API query with results union-merged and deduplicated by item ID. The parser lives in the shared client library so both the export tool and MCP server (via list_items) get OR support automatically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unused tempfile import and apply ruff formatting to query.py and test_query_unit.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment on lines
+80
to
+97
| # Check for OR keyword (outside quotes, outside parens) | ||
| if paren_depth == 0 and ch in ("O", "o") and query[i : i + 2] == "OR": | ||
| # Ensure OR is whitespace-bounded | ||
| before_ok = (i == 0) or query[i - 1] in (" ", "\t") | ||
| after_ok = (i + 2 >= n) or query[i + 2] in (" ", "\t") | ||
| if before_ok and after_ok: | ||
| found_or = True | ||
| token = "".join(current).strip() | ||
| if token: | ||
| # Text before OR that's not in a group — means OR without parens | ||
| if not found_parens: | ||
| raise ValueError("OR requires parenthesized groups") | ||
| raise ValueError( | ||
| "Filter terms after the last group are not allowed" | ||
| ) | ||
| current = [] | ||
| i += 2 | ||
| continue |
Contributor
Author
There was a problem hiding this comment.
Fixed in d319975. Added expect_group and expect_or state tracking:
(a) ORnow raises"OR must be followed by a parenthesized group"(a) (b)now raises"Expected OR between groups; consecutive groups require OR"
Added unit tests for both cases.
- Add expect_group/expect_or state tracking to reject trailing OR without a following group and consecutive groups without OR between - Fix unmatched quote error message (was incorrectly saying 'Unmatched opening parenthesis') - Use _extract_node_id() helper for dedup in list_items() OR path to avoid mixed str/int keys - Fix integration test to assert items from both M4.0 and M4.1 milestones (was checking wrong milestone) - Add 3 new unit tests for the new error conditions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rjan90
reviewed
May 8, 2026
OR queries fetch all matching items in a single request, so cursor-based pagination doesn't apply. Passing a cursor now raises ValueError. Added a configurable max_or_items parameter (default 1000) to prevent runaway queries from overwhelming the server. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
I'm going to merge since incorporated feedback and want to get this in before kick off other refactoring. |
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.
Background
I wanted this because for weekly reporting I want to pull open issues and recently completed:
Summary
expand_or_query()parser ingithub-projects-clientthat expands shared-prefix OR syntax (prefix (branch1) OR (branch2)) into multiple individual queriesexport_rows()(github-project-export) andlist_items()(github-projects-client/MCP server) with deduplication by item IDDetails
Each OR branch becomes a separate REST API query; results are union-merged with deduplication (by
item["id"]for raw items,_node_idfor formatted items). The parser is a pure function in the shared client library so both the export tool and MCP server benefit.Syntax:
shared-prefix (branch-1) OR (branch-2) OR (branch-3)Limitations (documented in README): single-level OR only — no nested parens, no AND keyword, no trailing terms after last group.
Test plan
cd github-projects-client && uv run pytest tests/test_query_unit.py -vcd github-project-export && uv run pytest tests/test_config_validation.py -vcd github-projects-client && GITHUB_TOKEN=$(gh auth token) uv run pytest -vcd github-project-export && GITHUB_TOKEN=$(gh auth token) uv run pytest -vm4.2.config.json) produces correct output🤖 Generated with Claude Code