andygrunwald / andygrunwald/go-jira

SearchOptions {MaxResults: 0} doesn't work

Đang mở
#299 6 bình luận 0 reaction 0 người được giao Xem trên GitHub
needs triage
Ngôn ngữ chính
Go
Star
1.6k
Fork
500
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## Describe the bug

`SearchOptions{ MaxResults:0 }` doesn't work. The API actually allows it and it's useful to get just the metadata.

## Expected behavior

No `Issue` returned if queried with `SearchOptions{ MaxResults:0 }`

```
// a piece of sample code
opts := jira.SearchOptions{ MaxResults: 0 }
issues, resp, _ := jiraCli.Issue.Search(`project=foo`, &opts)
fmt.Printf("NumIssues: %d, MaxResults: %d, Total: %d\n", len(issues), resp.MaxResults, resp.Total)

// expected output
NumIssues: 0, MaxResults: 0, Total: 12345

// actual output
NumIssues: 50, MaxResults: 50, Total: 12345
```

## Possible Solution

Remove `omitempty` from `MaxResults`

https://github.com/andygrunwald/go-jira/blob/f50cb07b297d79138b13e5ab49ea33965d32f5c1/issue.go#L500-L510

and tweak `if` conditions.

https://github.com/andygrunwald/go-jira/blob/f50cb07b297d79138b13e5ab49ea33965d32f5c1/issue.go#L1049-L1051

https://github.com/andygrunwald/go-jira/blob/f50cb07b297d79138b13e5ab49ea33965d32f5c1/issue.go#L1094-L1096

## Your Environment

* go-jira version (git tag or sha): v1.12.0
* Go version (`go version`): 1.14.2
* Jira type (cloud or on-premise): cloud
* Operating System and version: CentOS 8.1.1911

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

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

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.