Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: PG::SyntaxError (MAYBE-MARKETING-3C) #254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/stock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
scope :search, ->(query) {
return nil if query.blank? || query.length < 2

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

Check failure on line 39 in app/models/stock.rb

View workflow job for this annotation

GitHub Actions / lint

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
.reject(&:blank?)
.map { |term| "#{term}:*" }
.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
Loading