Searches in brackets matched everything
Merged · Pull request #549
The problem. Search on the Actions page dropped the last word inside brackets and ignored a minus in front of them. (housing) matched every item, (transit or bike) only searched for transit, and -(towing) showed only towing items instead of hiding them. Email alerts use the same code, so someone subscribed to (housing) got an email for every new item.
The fix. The query parser counted the closing bracket’s position from after the opening bracket, then used it as if it counted from the start. I converted it to the right position in the two places that handle brackets, the ( case and the -( case, and left the rest of the parser alone. Searches without brackets behave exactly as before, and a workflow that rebuilds saved subscriptions on merge fixes existing alerts automatically.
How I tested it. I ran the parser directly on nine queries, including empty brackets, an unclosed bracket and nested groups, and checked each against the expected Postgres text-search query. On the site, housing and (housing) now return the same results.





