lib/pg_search/features/tsearch.rb in pg_search-2.1.2 vs lib/pg_search/features/tsearch.rb in pg_search-2.1.3
- old
+ new
@@ -91,11 +91,11 @@
else
value
end
end
- DISALLOWED_TSQUERY_CHARACTERS = /['?\\:]/
+ DISALLOWED_TSQUERY_CHARACTERS = /['?\\:‘’]/.freeze
def tsquery_for_term(unsanitized_term) # rubocop:disable Metrics/AbcSize
if options[:negation] && unsanitized_term.start_with?("!")
unsanitized_term[0] = ''
negated = true
@@ -126,9 +126,10 @@
).to_sql
end
def tsquery
return "''" if query.blank?
+
query_terms = query.split(" ").compact
tsquery_terms = query_terms.map { |term| tsquery_for_term(term) }
tsquery_terms.join(options[:any_word] ? ' || ' : ' && ')
end