Skip to content

Commit

Permalink
Fix: PG::SyntaxError (MAYBE-MARKETING-2F) (#223)
Browse files Browse the repository at this point in the history
Co-authored-by: revise-dev[bot] <181657630+revise-dev[bot]@users.noreply.github.com>
  • Loading branch information
revise-dev[bot] authored Jan 6, 2025
1 parent 444370c commit 4d85f98
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/stock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Stock < ApplicationRecord
scope :search, ->(query) {
return nil if query.blank? || query.length < 2

sanitized_query = query.split.map { |term| "#{term}:*" }.join(" & ")
sanitized_query = query.split.map { |term| "#{term.gsub(/[()&|!:*]/, '')}:*" }.join(" & ")

select("stocks.*, ts_rank_cd(search_vector, to_tsquery('simple', $1)) AS rank")
.where("search_vector @@ to_tsquery('simple', :q)", q: sanitized_query)
Expand Down

0 comments on commit 4d85f98

Please sign in to comment.