Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove parentheses and curly braces from FTS5 search queries #213

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

Haitham-ghaida
Copy link
Contributor

Problem

FTS5 search fails with a syntax error when searching for strings containing parentheses () or curly braces {}, as these have special meaning in FTS5 query syntax.

For example, this search fails with an error:

act = db.search('market for sawnwood, beam, softwood, dried (u=10%), planed')

OperationalError: fts5: syntax error near "dried"

This affects searches for product specifications like "dried (u=10%)"

Solution

Modified the search query to strip parentheses and curly braces before passing to FTS5. This allows the search to work with these special characters while maintaining the search functionality.

Testing

  • Added test case verifying search works with parentheses
  • Ran full test suite locally, all tests pass

Resolves FTS5 syntax errors that occur when searching for terms
containing () or {} characters
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.93%. Comparing base (0c61d18) to head (fd16e5b).
Report is 132 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
+ Coverage   83.24%   84.93%   +1.69%     
==========================================
  Files          39       42       +3     
  Lines        3730     4355     +625     
==========================================
+ Hits         3105     3699     +594     
- Misses        625      656      +31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cmutel cmutel merged commit 4fd8e93 into brightway-lca:main Dec 5, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants