lib/pg_search/features/trigram.rb in pg_search-0.7.0 vs lib/pg_search/features/trigram.rb in pg_search-0.7.1

- old
+ new

@@ -1,29 +1,34 @@ module PgSearch module Features class Trigram < Feature def conditions Arel::Nodes::Grouping.new( - Arel::Nodes::InfixOperation.new("%", normalized_document, normalize(query)) + Arel::Nodes::InfixOperation.new("%", normalized_document, normalized_query) ) end def rank Arel::Nodes::Grouping.new( Arel::Nodes::NamedFunction.new( "similarity", [ normalized_document, - normalize(query) + normalized_query ] ) ) end private def normalized_document - Arel::Nodes::Grouping.new(normalize(Arel.sql(document))) + Arel::Nodes::Grouping.new(Arel.sql(normalize(document))) + end + + def normalized_query + sanitized_query = connection.quote(query) + Arel.sql(normalize(sanitized_query)) end end end end