Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove usage of #arel_wrap in Trigram feature

  • Loading branch information...
commit 4cb53761e945a0f373fc6c428ba3765dd05f6269 1 parent 243cf43
@nertzy nertzy authored
Showing with 15 additions and 4 deletions.
  1. +15 −4 lib/pg_search/features/trigram.rb
View
19 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
Please sign in to comment.
Something went wrong with that request. Please try again.