Repository navigation
test: add more tests for search_repository - #181
Merged
Merged
Conversation
- Add _prepare_boolean_query method to parse Boolean queries and quote individual terms - Add _prepare_single_term method to handle single term preparation logic - Update _prepare_search_term to use new Boolean query processing - Simplify search method by removing redundant Boolean handling logic - Add test cases for hyphenated terms with Boolean operators This fixes the issue where queries like "tier1-test AND unicode" would cause SQL parsing errors because FTS5 was treating "tier1-test" as a column name instead of a search term. The fix ensures that: - Boolean operators (AND, OR, NOT) are preserved - Terms with special characters (hyphens, dots, etc.) are properly quoted - Simple terms in Boolean queries remain unquoted for optimal FTS5 performance - Complex Boolean expressions with parentheses are handled correctly Fixes #178 Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
- Move import re to top of file instead of inside method - Simplify Boolean operator regex pattern to avoid nested capture groups - Use simple string matching for Boolean operators instead of regex fullmatch - Simplify parentheses handling to focus on core Boolean parsing - Fixes test failures for hyphenated terms with Boolean operators Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
- Add _prepare_parenthetical_term() method to preserve parentheses for grouping - Add _needs_quoting() helper method for cleaner quoting logic - Fix parentheses being quoted incorrectly in Boolean expressions - Ensure queries like "(hello AND world) OR test" work correctly - Maintain proper quoting for hyphenated terms within parentheses Fixes failing tests: - test_boolean_operators_preserved - test_hyphenated_terms_with_boolean_operators 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive test cases to cover previously untested edge cases: - Boolean query parsing with empty parts after regex splitting - Quote escaping in parenthetical terms with double quotes - Empty input validation for _needs_quoting() method - Empty input handling for _prepare_single_term() method These tests target specific lines identified in coverage gaps: - Line 143: Empty parts in Boolean query parsing - Lines 190-191: Quote escaping in parenthetical expressions - Line 207: Empty input validation - Line 227: Empty term handling Coverage improved from 28% to 89% for search_repository.py with all new tests passing and existing functionality preserved. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Add tests to get search_repository coverage to 100%