diff --git a/app/models/theme_field.rb b/app/models/theme_field.rb index dcf61cc24b1..6b64ee379ca 100644 --- a/app/models/theme_field.rb +++ b/app/models/theme_field.rb @@ -20,12 +20,12 @@ class ThemeField < ActiveRecord::Base return none unless locale_codes.present? where(target_id: Theme.targets[:translations], name: locale_codes) - .joins(self.sanitize_sql_array([ + .joins(DB.sql_fragment( "JOIN ( SELECT * FROM (VALUES #{locale_codes.map { "(?)" }.join(",")}) as Y (locale_code, locale_sort_column) ) as Y ON Y.locale_code = theme_fields.name", *locale_codes.map.with_index { |code, index| [code, index] } - ])) + )) .order("Y.locale_sort_column") } diff --git a/app/models/topic.rb b/app/models/topic.rb index 8e761c33f03..e425bb56495 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -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 diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 7070263e6fd..f5253eadad7 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -146,7 +146,7 @@ class TopicQuery # strip out users in groups you already belong to target_users = target_users - .joins("LEFT JOIN group_users gu ON gu.user_id = topic_allowed_users.user_id AND #{ActiveRecord::Base.sanitize_sql_array(['gu.group_id IN (?)', my_group_ids])}") + .joins("LEFT JOIN group_users gu ON gu.user_id = topic_allowed_users.user_id AND #{DB.sql_fragment('gu.group_id IN (?)', my_group_ids)}") .where('gu.group_id IS NULL') end @@ -1014,7 +1014,7 @@ class TopicQuery messages.joins(" LEFT JOIN topic_allowed_users ta2 ON topics.id = ta2.topic_id - AND #{ActiveRecord::Base.sanitize_sql_array(['ta2.user_id IN (?)', user_ids])} + AND #{DB.sql_fragment('ta2.user_id IN (?)', user_ids)} ") end @@ -1023,7 +1023,7 @@ class TopicQuery messages.joins(" LEFT JOIN topic_allowed_groups tg2 ON topics.id = tg2.topic_id - AND #{ActiveRecord::Base.sanitize_sql_array(['tg2.group_id IN (?)', group_ids])} + AND #{DB.sql_fragment('tg2.group_id IN (?)', group_ids)} ") end @@ -1046,7 +1046,7 @@ class TopicQuery LEFT JOIN group_users gu ON gu.user_id = #{@user.id.to_i} AND gu.group_id = _tg.group_id - WHERE #{ActiveRecord::Base.sanitize_sql_array(['gu.group_id IN (?)', group_ids])} + WHERE #{DB.sql_fragment('gu.group_id IN (?)', group_ids)} ) tg ON topics.id = tg.topic_id ") .where("tg.topic_id IS NOT NULL")