Skip to content

Commit

Permalink
Merge f41d27d into 60dae3f
Browse files Browse the repository at this point in the history
  • Loading branch information
ajb committed Jul 10, 2013
2 parents 60dae3f + f41d27d commit 6ed1c7a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/pg_search/features/tsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def tsquery
end

def tsdocument
if options[:tsvector_column]
if options[:tsvector_column] && columns.empty?
column_name = connection.quote_column_name(options[:tsvector_column])
"#{quoted_table_name}.#{column_name}"
else
columns.map do |search_column|
return_str = columns.map do |search_column|
tsvector = Arel::Nodes::NamedFunction.new(
"to_tsvector",
[dictionary, Arel.sql(normalize(search_column.to_sql))]
Expand All @@ -70,6 +70,13 @@ def tsdocument
"setweight(#{tsvector}, #{connection.quote(search_column.weight)})"
end
end.join(" || ")

if options[:tsvector_column]
column_name = connection.quote_column_name(options[:tsvector_column])
return_str += " || #{quoted_table_name}.#{column_name}"
end

return_str
end
end

Expand Down

0 comments on commit 6ed1c7a

Please sign in to comment.