Skip to content

Searching for issues and expanding fields #202

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
rikonor opened this issue Apr 2, 2019 · 3 comments
Closed

Searching for issues and expanding fields #202

rikonor opened this issue Apr 2, 2019 · 3 comments

Comments

@rikonor
Copy link

rikonor commented Apr 2, 2019

Hi,

I'm trying to search for issues and expand issue comments, but am having some trouble.

Here's an example of what I'm doing:

// fetches issues successfully based on query but does not expand anything
iss, _, err := jiraClient.Issue.Search(q, nil)

// for some reason this returns nothing
iss, _, err := jiraClient.Issue.Search(q, &jira.SearchOptions{})

// also finds nothing, not sure how to expand the comments
iss, _, err := jiraClient.Issue.Search(q, &jira.SearchOptions{
	Expand: "comments",
})

I can repeat fetching an issue with Get to get the comments, but I figure that's a really inefficient way to do it.

Any chance you might have some idea how to do this properly?

Thank you!

@rikonor rikonor closed this as completed Apr 2, 2019
@ghostsquad
Copy link
Contributor

@rikonor did you solve your own problem? If so, can you document that here in case someone else runs into a similar issue?

@rikonor
Copy link
Author

rikonor commented Apr 2, 2019

@ghostsquad Sorry, I figured it out a few minutes after posting this. It was just a matter of including a MaxResults in the options. I think it might be nicer if in Search, it would build the query params based on which options were set, e.g if MaxResults is 0, not include that query params in the URL, etc, which would be equivalent to providing a nil options argument.

@ghostsquad
Copy link
Contributor

ghostsquad commented Apr 3, 2019

@rikonor that's the problem with using structs as options. Zero values have meaning. Here's more information about this problem: https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

I'll keep this in mind for changes in V2 (#200)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants