diff --git a/database/postgres/utils.go b/database/postgres/utils.go index 1d5f157..85c625a 100644 --- a/database/postgres/utils.go +++ b/database/postgres/utils.go @@ -16,16 +16,15 @@ func TSQueryFromSearch(search string) string { clearQuotes := false startQuotes := false - if strings.HasPrefix(token, "\"") { - if len(token) > 1 { - token = token[1:] - } + if strings.HasPrefix(token, "\"") && len(token) > 1 { startQuotes = true } if strings.HasSuffix(token, "\"") { - token = token[:len(token)-1] + if !startQuotes { + clearQuotes = true + } + startQuotes = false - clearQuotes = true } token := strings.Trim(token, ",.;:()\"") diff --git a/database/postgres/utils_test.go b/database/postgres/utils_test.go index fedee12..fc14301 100644 --- a/database/postgres/utils_test.go +++ b/database/postgres/utils_test.go @@ -13,6 +13,7 @@ func TestTSQueryFromSearch(t *testing.T) { {`"asari matron" blue`, `(asari<->matron) & blue`}, {`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`}, {`stuff`, `stuff`}, + {`"stuff"`, `stuff`}, {`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`}, }