Incrementing a value into the negative does not work
- 主要语言
- Ruby
- 星标
- 700
- 派生
- 29
- PR 合并指标
- 30 天内没有已合并 PR
描述
When using the [`increment`](https://github.com/github/github-ds/blob/f964ab2d75272d5b5d2fef68416abcab7bd2dc3a/lib/github/kv.rb#L287) method, if you increment the value below 0, the output is unexpected and subsequent `increment`s fail.
```ruby
> 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'
```
贡献指南
调研方向
Start in lib/github/kv.rb at the increment method around line 287 and reproduce the documented sequence, including the negative amount. Done means incrementing below zero produces the intended value and a later positive increment no longer raises InvalidValueError; add or update focused coverage if the repository provides a relevant test location.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- ruby
- 领域
- database
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100