Files
buzz/crates
Tom Brow e715fbb362 fix(relay): treat empty filter sets as match-nothing in SQL (#9342)
Fix for a COUNT regression introduced by #9339 (now on main), found in
its review.

With #9339, a filter with a nonempty `#a` takes the exact SQL COUNT
path. But `filter_to_query_params` dropped an empty `authors`, `ids` or
`#e` list and never represented an empty `#p`, `#d` or unpushed tag set.
So `{"kinds":[7], "#a":[A], "authors":[]}` counted every reaction to
`A`, while REQ (which post-filters) correctly returned nothing. Before
#9339 that COUNT returned 0. The same gap already existed for filters
without `#a`.

Any empty `authors`, `ids` or tag set now maps to the existing `kinds:
[]` match-nothing sentinel, which every read (REQ, COUNT, `/query`,
`/count`) answers without a query. An empty string value such as `"#d":
[""]` is still a real constraint.

Why nothing gets worse: only filters that provably match nothing change,
and they now skip the database instead of reading or counting.

### Validation

Added tests:
- Unit table over empty `authors`, `ids`, `#e`, `#p`, `#d`, `#h`, `#k`
and `#t`, each with and without `#a`, plus `"#d": [""]`. It fails with
the sentinel disabled.
- Postgres table: WebSocket and HTTP COUNT are 0, and REQ and `/query`
are empty, for each empty set beside a matching `#a` and for
`{kinds:[7], authors:[]}`. The first commit contains only the tests.

Existing workspace unit tests pass (pre-push). The Postgres lanes run
separately on an isolated cluster.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:21:21 -08:00
..