Commit 15fea945 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'id-fix-arel-usage' into 'master'

Make Arel usages compatible with Rails 6.1 changes

See merge request gitlab-org/gitlab!60778
parents 60fe63c9 d484a7b9
...@@ -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
) )
......
...@@ -9,6 +9,8 @@ class RemoveDuplicateLabelsFromProject < ActiveRecord::Migration[6.0] ...@@ -9,6 +9,8 @@ class RemoveDuplicateLabelsFromProject < ActiveRecord::Migration[6.0]
disable_ddl_transaction! disable_ddl_transaction!
class BackupLabel < Label class BackupLabel < Label
self.inheritance_column = :_type_disabled
self.table_name = 'backup_labels' self.table_name = 'backup_labels'
end end
......
...@@ -12,7 +12,7 @@ module EE ...@@ -12,7 +12,7 @@ module EE
prepended do prepended do
scope :latest, -> do scope :latest, -> do
with( with(
latest_by_project: select(:project_id, 'MAX(date) AS date').group(:project_id) ::Gitlab::SQL::CTE.new(:latest_by_project, select(:project_id, 'MAX(date) AS date').group(:project_id)).to_arel
) )
.joins( .joins(
'JOIN latest_by_project ON ci_daily_build_group_report_results.date = latest_by_project.date 'JOIN latest_by_project ON ci_daily_build_group_report_results.date = latest_by_project.date
......
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