FIX: use sql_fragment instead of sanitize_sql_array (#11460)

This is a follow up to comment under this PR https://github.com/discourse/discourse/pull/11441

Sam suggested using sql_fragment instead of sanitize_sql_array
This commit is contained in:
Krzysztof Kotlarek
2020-12-11 10:56:26 +11:00
committed by GitHub
parent aa0d4ea764
commit 3ea4f36f26
3 changed files with 8 additions and 8 deletions

View File

@@ -636,11 +636,11 @@ class Topic < ActiveRecord::Base
if raw.present?
similars
.select(sanitize_sql_array(["topics.*, similarity(topics.title, :title) + similarity(p.raw, :raw) AS similarity, p.cooked AS blurb", title: title, raw: raw]))
.select(DB.sql_fragment("topics.*, similarity(topics.title, :title) + similarity(p.raw, :raw) AS similarity, p.cooked AS blurb", title: title, raw: raw))
.where("similarity(topics.title, :title) + similarity(p.raw, :raw) > 0.2", title: title, raw: raw)
else
similars
.select(sanitize_sql_array(["topics.*, similarity(topics.title, :title) AS similarity, p.cooked AS blurb", title: title]))
.select(DB.sql_fragment("topics.*, similarity(topics.title, :title) AS similarity, p.cooked AS blurb", title: title))
.where("similarity(topics.title, :title) > 0.2", title: title)
end
end