Permalink
Browse files

Remove usage of #arel_wrap in Trigram feature

  • Loading branch information...
1 parent 243cf43 commit 4cb53761e945a0f373fc6c428ba3765dd05f6269 @nertzy nertzy committed Apr 2, 2013
Showing with 15 additions and 4 deletions.
  1. +15 −4 lib/pg_search/features/trigram.rb
@@ -3,16 +3,27 @@ module Features
class Trigram < Feature
def conditions
Arel::Nodes::Grouping.new(
- Arel::Nodes::InfixOperation.new("%", arel_wrap(document), query)
+ Arel::Nodes::InfixOperation.new("%", normalized_document, normalize(query))
)
end
def rank
- arel_wrap(
- "similarity((#{normalize(document)}), #{normalize(":query")})",
- :query => query
+ Arel::Nodes::Grouping.new(
+ Arel::Nodes::NamedFunction.new(
+ "similarity",
+ [
+ normalized_document,
+ normalize(query)
+ ]
+ )
)
end
+
+ private
+
+ def normalized_document
+ Arel::Nodes::Grouping.new(normalize(Arel.sql(document)))
+ end
end
end
end

0 comments on commit 4cb5376

Please sign in to comment.