FIX: Ignore empty search terms in topic queries

Previously an empty search term would cause an invalid tsquery, and led to a 500 error. Now an empty string will be ignored.
This commit is contained in:
David Taylor
2020-09-10 15:49:11 +01:00
parent 53ffbc8d6e
commit 2f96474155
2 changed files with 4 additions and 1 deletions

View File

@@ -748,7 +748,7 @@ class TopicQuery
result = result.where('topics.id in (?)', options[:topic_ids]).references(:topics)
end
if search = options[:search]
if search = options[:search].presence
result = result.where("topics.id in (select pp.topic_id from post_search_data pd join posts pp on pp.id = pd.post_id where pd.search_data @@ #{Search.ts_query(term: search.to_s)})")
end