Add support for wildcard searches in text fields

#1663
This commit is contained in:
Toks
2013-07-20 16:51:55 -04:00
parent 0e7ce3397d
commit ecfcebe30a
7 changed files with 42 additions and 9 deletions

View File

@@ -18,7 +18,11 @@ class Comment < ActiveRecord::Base
end
def body_matches(query)
where("body_index @@ plainto_tsquery(?)", query.to_escaped_for_tsquery_split).order("comments.id DESC")
if query =~ /\*/ && CurrentUser.user.is_builder?
where("body ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
else
where("body_index @@ plainto_tsquery(?)", query.to_escaped_for_tsquery_split).order("comments.id DESC")
end
end
def hidden(user)