v0.37 pubsub/kvindexer: Handle big ints#771
Conversation
| valueBig, ok := valueBig.SetString(number, 10) | ||
| if !ok { | ||
| err := fmt.Errorf( | ||
| "problem parsing %s as bigint (should never happen if the grammar is correct)", |
There was a problem hiding this comment.
"if the grammar is correct" is not very helpful to the user.
Could we replace it for something like "please report the error to the development team"?
There was a problem hiding this comment.
As this is the default message in a bunch of other places and it actually makes sense - comparing the query to the query grammar, I would leave this?
sergio-mena
left a comment
There was a problem hiding this comment.
LGTM. I payed a lot of attention, but added some questions on parts I didn't fully understand.
| q: query.MustParse("block.height < 2 AND block.height > 0 AND block.height > 0"), | ||
| results: []int64{1}, | ||
| }, | ||
| "query matches fields with big int and height - no match": { |
There was a problem hiding this comment.
Can we add a similar test case that is testing an off-by-1 bigint value? (testing precision not lost, as done further up in another file)
There was a problem hiding this comment.
Added a use case, let me know if it covers what oyu had in mind.
.changelog/unreleased/bug-fixes/771-kvindexer-parsing-big-ints.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Lasaro <lasaro@informal.systems> Co-authored-by: Sergio Mena <sergio@informal.systems>
Replaced int64 with big.int Co-authored-by: Lasaro <lasaro@informal.systems> Co-authored-by: Sergio Mena <sergio@informal.systems>
Replaced int64 with big.int Co-authored-by: Lasaro <lasaro@informal.systems> Co-authored-by: Sergio Mena <sergio@informal.systems> Co-authored-by: Thane Thomson <connect@thanethomson.com>
| occurred within the same event. | ||
|
|
||
| # Event attribute value types | ||
| Users can use anything as an event value. However, if the even attrbute value is a number, the following restrictions apply: |
Replaced int64 with big.int Co-authored-by: Lasaro <lasaro@informal.systems> Co-authored-by: Sergio Mena <sergio@informal.systems>
Closes #726 for 0.37.x.
This is a draft PR. The main goal is to make sure that big integers are parsed properly without a loss of precision. Int64 values will be processed as before.
It also fixes the old logic where ints and floats were treated the same if a float had a fraction due to the fact that the float was converted to an int before comparison.
PR checklist
.changelog(we use unclog to manage our changelog)docs/orspec/) and code comments