From 3b4c4abacfa3362da05e55b8aa2119bd3df3ee8d Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Wed, 15 Sep 2021 12:22:12 -0400 Subject: [PATCH] internal/postgres/search: rename Query to SymbolQuery Query is renamed to SymbolQuery, since the package was renamed from symbolsearch to search. For golang/go#44142 Change-Id: I02c2f04305d604a3b4efc60708154bd53e07fd11 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/350130 Trust: Julie Qiu Reviewed-by: Jamal Carvalho --- internal/postgres/search/content.go | 6 +++--- internal/postgres/search/symbolsearch.go | 4 ++-- internal/postgres/search/symbolsearch_test.go | 6 +++--- internal/postgres/symbolsearch.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/postgres/search/content.go b/internal/postgres/search/content.go index 201ecdb8..ae3d43be 100644 --- a/internal/postgres/search/content.go +++ b/internal/postgres/search/content.go @@ -27,9 +27,9 @@ package search // querySearchMultiWordExact is used when the search query is multiple elements. %s `, - formatQuery("querySearchSymbol", Query(SearchTypeSymbol)), - formatQuery("querySearchPackageDotSymbol", Query(SearchTypePackageDotSymbol)), - formatQuery("querySearchMultiWordExact", Query(SearchTypeMultiWordExact))) + formatQuery("querySearchSymbol", SymbolQuery(SearchTypeSymbol)), + formatQuery("querySearchPackageDotSymbol", SymbolQuery(SearchTypePackageDotSymbol)), + formatQuery("querySearchMultiWordExact", SymbolQuery(SearchTypeMultiWordExact))) func formatQuery(name, query string) string { return fmt.Sprintf("const %s = `%s`", name, query) diff --git a/internal/postgres/search/symbolsearch.go b/internal/postgres/search/symbolsearch.go index c24092f8..19c8ba56 100644 --- a/internal/postgres/search/symbolsearch.go +++ b/internal/postgres/search/symbolsearch.go @@ -15,12 +15,12 @@ import ( // used for symbol search. const SymbolTextSearchConfiguration = "symbols" -// Query returns a symbol search query to be used in internal/postgres. +// SymbolQuery returns a symbol search query to be used in internal/postgres. // Each query that is returned accepts the following args: // $1 = query // $2 = limit // $3 = only used by multi-word-exact for path tokens -func Query(st SearchType) string { +func SymbolQuery(st SearchType) string { switch st { case SearchTypeMultiWordExact: return fmt.Sprintf(baseQuery, multiwordCTE) diff --git a/internal/postgres/search/symbolsearch_test.go b/internal/postgres/search/symbolsearch_test.go index 62c2a3f7..df9e323b 100644 --- a/internal/postgres/search/symbolsearch_test.go +++ b/internal/postgres/search/symbolsearch_test.go @@ -56,9 +56,9 @@ func TestGenerateQuery(t *testing.T) { for _, test := range []struct { name, q, want string }{ - {"querySearchSymbol", Query(SearchTypeSymbol), querySearchSymbol}, - {"querySearchPackageDotSymbol", Query(SearchTypePackageDotSymbol), querySearchPackageDotSymbol}, - {"querySearchMultiWordExact", Query(SearchTypeMultiWordExact), querySearchMultiWordExact}, + {"querySearchSymbol", SymbolQuery(SearchTypeSymbol), querySearchSymbol}, + {"querySearchPackageDotSymbol", SymbolQuery(SearchTypePackageDotSymbol), querySearchPackageDotSymbol}, + {"querySearchMultiWordExact", SymbolQuery(SearchTypeMultiWordExact), querySearchMultiWordExact}, } { t.Run(test.name, func(t *testing.T) { if diff := cmp.Diff(test.want, test.q); diff != "" { diff --git a/internal/postgres/symbolsearch.go b/internal/postgres/symbolsearch.go index ed7f20d7..c2b96a10 100644 --- a/internal/postgres/symbolsearch.go +++ b/internal/postgres/symbolsearch.go @@ -341,7 +341,7 @@ func runSymbolSearch(ctx context.Context, ddb *database.DB, results = append(results, &r) return nil } - query := search.Query(st) + query := search.SymbolQuery(st) args = append([]interface{}{q, limit}, args...) if err := ddb.RunQuery(ctx, query, collect, args...); err != nil { return nil, err