From 1cd4840199c64c393b233b09339367a27038edfb Mon Sep 17 00:00:00 2001 From: "Babak K. Shandiz" Date: Thu, 20 Nov 2025 13:35:24 +0000 Subject: [PATCH] fix(pr/shared): delegate query compilation to `search` package Signed-off-by: Babak K. Shandiz --- pkg/cmd/issue/list/list_test.go | 4 ++-- pkg/cmd/pr/list/http_test.go | 2 +- pkg/cmd/pr/list/list_test.go | 2 +- pkg/cmd/pr/shared/params.go | 14 ++++---------- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/pkg/cmd/issue/list/list_test.go b/pkg/cmd/issue/list/list_test.go index 83dc313ce..52f9ba00e 100644 --- a/pkg/cmd/issue/list/list_test.go +++ b/pkg/cmd/issue/list/list_test.go @@ -443,7 +443,7 @@ func Test_issueList(t *testing.T) { "owner": "OWNER", "repo": "REPO", "limit": float64(30), - "query": "auth bug assignee:@me author:@me mentions:@me repo:OWNER/REPO state:open type:issue", + "query": "( auth bug ) assignee:@me author:@me mentions:@me repo:OWNER/REPO state:open type:issue", "type": "ISSUE_ADVANCED", }, params) })) @@ -618,7 +618,7 @@ func TestIssueList_Search_withProjectItems(t *testing.T) { "repo": "REPO", "type": "ISSUE_ADVANCED", "limit": float64(30), - "query": "just used to force the search API branch repo:OWNER/REPO type:issue", + "query": "( just used to force the search API branch ) repo:OWNER/REPO type:issue", }, params) })) diff --git a/pkg/cmd/pr/list/http_test.go b/pkg/cmd/pr/list/http_test.go index 5f08498f7..ce7565e71 100644 --- a/pkg/cmd/pr/list/http_test.go +++ b/pkg/cmd/pr/list/http_test.go @@ -149,7 +149,7 @@ func Test_ListPullRequests(t *testing.T) { httpmock.GraphQL(`query PullRequestSearch\b`), httpmock.GraphQLQuery(`{"data":{}}`, func(query string, vars map[string]interface{}) { want := map[string]interface{}{ - "q": "one world in:title repo:OWNER/REPO state:open type:pr", + "q": "( one world in:title ) repo:OWNER/REPO state:open type:pr", "type": "ISSUE_ADVANCED", "limit": float64(30), } diff --git a/pkg/cmd/pr/list/list_test.go b/pkg/cmd/pr/list/list_test.go index 4953b8888..92b5834c0 100644 --- a/pkg/cmd/pr/list/list_test.go +++ b/pkg/cmd/pr/list/list_test.go @@ -441,7 +441,7 @@ func TestPRList_Search_withProjectItems(t *testing.T) { }`, func(_ string, params map[string]interface{}) { require.Equal(t, map[string]interface{}{ "limit": float64(30), - "q": "just used to force the search API branch repo:OWNER/REPO state:open type:pr", + "q": "( just used to force the search API branch ) repo:OWNER/REPO state:open type:pr", "type": "ISSUE_ADVANCED", }, params) })) diff --git a/pkg/cmd/pr/shared/params.go b/pkg/cmd/pr/shared/params.go index 9504ecef4..94fe5f4b1 100644 --- a/pkg/cmd/pr/shared/params.go +++ b/pkg/cmd/pr/shared/params.go @@ -222,19 +222,13 @@ func SearchQueryBuild(options FilterOptions, advancedIssueSearchSyntax bool) str Is: []string{is}, Type: options.Entity, }, + KeywordsVerbatim: options.Search, } - var q string - if advancedIssueSearchSyntax { - q = query.AdvancedIssueSearchString() - } else { - q = query.StandardSearchString() + if !advancedIssueSearchSyntax { + return query.StandardSearchString() } - - if options.Search != "" { - return fmt.Sprintf("%s %s", options.Search, q) - } - return q + return query.AdvancedIssueSearchString() } func QueryHasStateClause(searchQuery string) bool {