github / github/github-ds

Incrementing a value into the negative does not work

Đang mở
#65 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Ruby
Star
700
Fork
29
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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'
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
ruby
Lĩnh vực
database
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.