Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: handle empty ts query (#7826)

p0nyd72944922f0a
diff --git a/backend/store/issue.go b/backend/store/issue.go
index ad6b7598a1..c96e4f58ea 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -883,11 +883,12 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
where, args = append(where, fmt.Sprintf("issue.id <= $%d", len(args)+1)), append(args, *v)
}
if v := find.Query; v != nil && *v != "" {
- tsQuery := getTsQuery(*v)
- from += fmt.Sprintf(`, CAST($%d AS tsquery) AS query`, len(args)+1)
- args = append(args, tsQuery)
- where = append(where, "issue.ts_vector @@ query")
- orderByClause = "ORDER BY ts_rank(issue.ts_vector, query) DESC, issue.id DESC"
+ if tsQuery := getTsQuery(*v); tsQuery != "" {
+ from += fmt.Sprintf(`, CAST($%d AS tsquery) AS query`, len(args)+1)
+ args = append(args, tsQuery)
+ where = append(where, "issue.ts_vector @@ query")
+ orderByClause = "ORDER BY ts_rank(issue.ts_vector, query) DESC, issue.id DESC"
+ }
}
if len(find.StatusList) != 0 {
var list []string
@@ -1099,9 +1100,6 @@ func getTsQuery(text string) string {
}
_, _ = tsQuery.WriteString(fmt.Sprintf("%s:*", part))
}
- if tsQuery.Len() == 0 {
- return text
- }
return tsQuery.String()
}