зеркало из https://github.com/golang/pkgsite.git
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 <julie@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
This commit is contained in:
Родитель
1f178e21e8
Коммит
3b4c4abacf
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 != "" {
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче