You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Filters with two tag names match nothing and the first filter's limit caps multi-filter queries #789
A filter with two different tag names, like {"#e":["<id>"],"#p":["<pubkey>"]}, never matches a stored event. REQ gets EOSE with no events and COUNT returns 0, even when the relay has events carrying both tags.
findByFilters and countByFilters do a single left join on event_tags and put every tag condition on that one joined row. A row can't have tag_namee and p at the same time so nothing matches. Live events still match because isEventMatchingFilter checks each tag name separately. The same join also breaks ids combined with a tag filter, because event_id becomes ambiguous.
There's a second bug in the same code. With more than one filter, query.union(subqueries, true) leaves the first filter's ORDER BY and LIMIT after the UNION, so they apply to the combined result. A REQ ends up capped at the first filter's limit (or the default 500 if it has none), and a COUNT whose first filter has a limit fails.
To Reproduce
Publish a kind 7 event tagged ["e","<id>"] and ["p","<pubkey>"].
Send ["COUNT","c1",{"kinds":[7],"#e":["<id>"],"#p":["<pubkey>"]}]. You get {"count":0}, and a REQ with the same filter returns nothing.
For an author with two text notes and a profile, send ["REQ","r1",{"kinds":[1],"authors":["<pubkey>"],"limit":1},{"kinds":[0],"authors":["<pubkey>"]}]. Only 1 event comes back.
Send the same two filters as a COUNT. You get ["CLOSED","c2","error: unable to count events"].
Expected behavior
Tag names in a filter are ANDed and the values for each name are ORed, as NIP-01 says, so step 2 should return and count the event. Each limit should only apply to its own filter, so step 3 returns 2 events and step 4 counts 2.
Activity