fiatjaf / eventstore

an abstraction layer over databases for nostr events
The Unlicense
26 stars 15 forks source link

PostgreSQL tagvalues query problem #16

Closed haorendashu closed 4 months ago

haorendashu commented 4 months ago

This code:

https://github.com/fiatjaf/eventstore/blob/4c1b0497dfc1bb8050b3d0766322289225364a54/postgresql/query.go#L122

I think should change the && to @> .

Demos: id query result
demo1 ARRAY[1,2,3] @> ARRAY[1,2] true
demo2 ARRAY[1,2,3] @> ARRAY[1,4] false
demo3 ARRAY[1,2,3] && ARRAY[1,2] true
demo4 ARRAY[1,2,3] && ARRAY[1,4] true

if a filter like this, I think it should query the event contain both a tag with aaa value and p tag with ppp value, just like demo1 not demo4

{
"#a": "aaa",
"#p": "ppp"
}
fiatjaf commented 4 months ago

I may be missing something, but I think you are correct. This is a bug.