github-ds icon indicating copy to clipboard operation
github-ds copied to clipboard

Incrementing a value into the negative does not work

Open scotttesler opened this issue 2 years ago • 0 comments

When using the increment method, if you increment the value below 0, the output is unexpected and subsequent increments fail.

> GitHub.kv.get(kv_key).value! { 0 }
nil

> GitHub.kv.increment(kv_key)
1

> GitHub.kv.get(kv_key).value! { 0 }
"1"

> GitHub.kv.increment(kv_key, amount: -2)
18446744073709551615

> GitHub.kv.get(kv_key).value! { 0 }
"18446744073709551615"

> GitHub.kv.increment(kv_key, amount: 2)
eval error: GitHub::KV::InvalidValueError
  vendor/gems/3.2.2/ruby/3.2.0/gems/github-ds-0.5.2.10.g8cf56ba:in `block in increment'

scotttesler avatar Aug 24 '23 21:08 scotttesler