Permalink
Browse files

extract common to_tsvector-string

  • Loading branch information...
1 parent b845140 commit a52612f4a00b852306134b129d21911619a9a8b9 @kronn kronn committed with tenderlove Nov 30, 2010
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/texticle/full_text_index.rb
@@ -40,11 +40,12 @@ def to_s
vectors = []
@index_columns.sort_by { |k,v| k }.each do |weight, columns|
c = columns.map { |x| "coalesce(\"#{@model_class.table_name}\".\"#{x}\", '')" }
+ ts_vector = "to_tsvector('#{@dictionary}', #{c.join(" || ' ' || ")})"
+
if weight == 'none'
- vectors << "to_tsvector('#{@dictionary}', #{c.join(" || ' ' || ")})"
+ vectors << ts_vector
else
- vectors <<
- "setweight(to_tsvector('#{@dictionary}', #{c.join(" || ' ' || ")}), '#{weight}')"
+ vectors << "setweight(#{ts_vector}, '#{weight}')"
end
end
@string = vectors.join(" || ' ' || ")

0 comments on commit a52612f

Please sign in to comment.