Add EXISTS condition to query grammar#4077
Add EXISTS condition to query grammar#4077melekes merged 13 commits intotendermint:masterfrom haasted:add-occurs
Conversation
| for c := 0; c < int(token.next); c++ { | ||
| fmt.Printf(" ") | ||
| } | ||
| fmt.Printf("\x1B[34m%v\x1B[m %v\n", rul3s[token.pegRule], strconv.Quote(string(([]rune(buffer)[token.begin:token.end])))) |
There was a problem hiding this comment.
line is 123 characters (from lll)
|
Alternative syntax proposal: |
|
@melekes : I like the idea of using JSON-query, although I see two arguments against it:
|
|
I am not entirely sure js-query is a good idea, but extending current format without clear understanding how it will evolve is either bad. |
|
|
melekes
left a comment
There was a problem hiding this comment.
Could you please add an entry to CHANGELOG_PENDING.md?
Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com>
libs/pubsub/query/query.go
Outdated
|
|
||
| loop: | ||
| for k := range events { | ||
| if strings.Index(k, tag) == 0 { |
There was a problem hiding this comment.
why Index? Shouldn't we use strict comparison here ?
| if strings.Index(k, tag) == 0 { | |
| if k == tag { |
There was a problem hiding this comment.
This is the case where the query is the "event type", e.g. just "slash". The contents of the events slice are the fully qualified event attributes, e.g. slash.reason. The index is used to verify that the event starts with the tag from the query.
There was a problem hiding this comment.
Won't it lead to false positives? I.e. sl EXISTS will work for slash.reason, but I doubt that it's what we want.
There was a problem hiding this comment.
sl EXISTS is valid syntax in the current implementation. Not sure whether I would consider it a problem.
There was a problem hiding this comment.
This needs to be reflected both in the docs
tendermint/rpc/swagger/swagger.yaml
Line 155 in 2df4ca0
|
#4077 (comment) needs to be addressed before we can merge. |
|
Addressed comments. |
This PR adds an "EXISTS" condition to the event query grammar. It enables querying for the occurrence of an event without having to provide a condition for one of its attributes.
As an example, someone interested in all slashing events might currently catch them with a query such as
slash.power > 0.With this PR the event can be captured with
slash.power EXISTSor justslash EXISTSto catch by event type.