Skip to content

Commit bf29a93

Browse files
authored
updated jira.search_issues default behaviour to include all fields (#1360)
The `jira.search_issues` documentation states that when nothing is passed to the field parameter, all fields are returned. https://jira.readthedocs.io/api.html?highlight=search_issues#jira.client.JIRA.search_issues The "*all" has been set as the default field parameter to achieve this.
1 parent 39a74e5 commit bf29a93

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

jira/client.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,7 @@ def search_issues(
28702870
startAt: int = 0,
28712871
maxResults: int = 50,
28722872
validate_query: bool = True,
2873-
fields: Optional[Union[str, List[str]]] = None,
2873+
fields: Optional[Union[str, List[str]]] = "*all",
28742874
expand: Optional[str] = None,
28752875
json_result: bool = False,
28762876
) -> Union[List[Dict[str, Any]], ResultList[Issue]]:
@@ -2895,8 +2895,6 @@ def search_issues(
28952895
"""
28962896
if isinstance(fields, str):
28972897
fields = fields.split(",")
2898-
else:
2899-
fields = list(fields or [])
29002898

29012899
# this will translate JQL field names to REST API Name
29022900
# most people do know the JQL names so this will help them use the API easier

tests/resources/test_issue.py

+23
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ def test_issue(self):
2626
self.assertEqual(issue.key, self.issue_1)
2727
self.assertEqual(issue.fields.summary, "issue 1 from %s" % self.project_b)
2828

29+
def test_issue_search_finds_issue(self):
30+
issues = self.jira.search_issues("key=%s" % self.issue_1)
31+
self.assertEqual(self.issue_1, issues[0].key)
32+
33+
def test_issue_search_return_type(self):
34+
issues = self.jira.search_issues("key=%s" % self.issue_1)
35+
self.assertIsInstance(issues, list)
36+
issues = self.jira.search_issues("key=%s" % self.issue_1, json_result=True)
37+
self.assertIsInstance(issues, dict)
38+
39+
def test_issue_search_only_includes_provided_fields(self):
40+
issues = self.jira.search_issues(
41+
"key=%s" % self.issue_1, fields="comment,assignee"
42+
)
43+
self.assertTrue(hasattr(issues[0].fields, "comment"))
44+
self.assertTrue(hasattr(issues[0].fields, "assignee"))
45+
self.assertFalse(hasattr(issues[0].fields, "reporter"))
46+
47+
def test_issue_search_default_behaviour_included_fields(self):
48+
issues = self.jira.search_issues("key=%s" % self.issue_1)
49+
self.assertTrue(hasattr(issues[0].fields, "reporter"))
50+
self.assertTrue(hasattr(issues[0].fields, "comment"))
51+
2952
def test_issue_get_field(self):
3053
issue = self.jira.issue(self.issue_1)
3154
self.assertEqual(

0 commit comments

Comments
 (0)