Commit 4c8c5a0a authored by Igor Drozdov's avatar Igor Drozdov

Do not pass AR object to Arel quotes

parent 06dd3bcf
...@@ -103,7 +103,7 @@ module Issuable ...@@ -103,7 +103,7 @@ module Issuable
end end
scope :assigned_to, ->(u) do scope :assigned_to, ->(u) do
assignees_table = Arel::Table.new("#{to_ability_name}_assignees") assignees_table = Arel::Table.new("#{to_ability_name}_assignees")
sql = assignees_table.project('true').where(assignees_table[:user_id].in(u)).where(Arel::Nodes::SqlLiteral.new("#{to_ability_name}_id = #{to_ability_name}s.id")) sql = assignees_table.project('true').where(assignees_table[:user_id].in(u.id)).where(Arel::Nodes::SqlLiteral.new("#{to_ability_name}_id = #{to_ability_name}s.id"))
where("EXISTS (#{sql.to_sql})") where("EXISTS (#{sql.to_sql})")
end end
# rubocop:enable GitlabSecurity/SqlInjection # rubocop:enable GitlabSecurity/SqlInjection
......
...@@ -381,7 +381,7 @@ class MergeRequest < ApplicationRecord ...@@ -381,7 +381,7 @@ class MergeRequest < ApplicationRecord
scope :review_requested_to, ->(user) do scope :review_requested_to, ->(user) do
where( where(
reviewers_subquery reviewers_subquery
.where(Arel::Table.new("#{to_ability_name}_reviewers")[:user_id].eq(user)) .where(Arel::Table.new("#{to_ability_name}_reviewers")[:user_id].eq(user.id))
.exists .exists
) )
end end
...@@ -389,7 +389,7 @@ class MergeRequest < ApplicationRecord ...@@ -389,7 +389,7 @@ class MergeRequest < ApplicationRecord
scope :no_review_requested_to, ->(user) do scope :no_review_requested_to, ->(user) do
where( where(
reviewers_subquery reviewers_subquery
.where(Arel::Table.new("#{to_ability_name}_reviewers")[:user_id].eq(user)) .where(Arel::Table.new("#{to_ability_name}_reviewers")[:user_id].eq(user.id))
.exists .exists
.not .not
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment