FIX: add more quoting to avoid invalid terms

This commit is contained in:
Sam 2015-08-19 09:27:47 +10:00
parent 27b1ec2917
commit b38a1309f7
2 changed files with 2 additions and 2 deletions

View File

@ -481,7 +481,7 @@ class Search
t.split(/[\)\(&']/)[0]
end.compact!
query = Post.sanitize(all_terms.map {|t| "#{PG::Connection.escape_string(t)}:*"}.join(" #{joiner} "))
query = Post.sanitize(all_terms.map {|t| "'#{PG::Connection.escape_string(t)}':*"}.join(" #{joiner} "))
"TO_TSQUERY(#{locale || query_locale}, #{query})"
end

View File

@ -447,7 +447,7 @@ describe Search do
it 'can parse complex strings using ts_query helper' do
str = " grigio:babel deprecated? "
str << "page page on Atmosphere](https://atmospherejs.com/grigio/babel)xxx: aaa'\"bbb"
str << "page page on Atmosphere](https://atmospherejs.com/grigio/babel)xxx: aaa.js:222 aaa'\"bbb"
ts_query = Search.ts_query(str, "simple")
Post.exec_sql("SELECT to_tsvector('bbb') @@ " << ts_query)