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:
parent
53ffbc8d6e
commit
2f96474155
|
@ -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
|
||||
|
||||
|
|
|
@ -52,6 +52,9 @@ RSpec.describe ListController do
|
|||
|
||||
get "/latest.json?page=2147483647"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
get "/latest?search="
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
(Discourse.anonymous_filters - [:categories]).each do |filter|
|
||||
|
|
Loading…
Reference in New Issue