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
end
scope :assigned_to, ->(u) do
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})")
end
# rubocop:enable GitlabSecurity/SqlInjection
......
......@@ -381,7 +381,7 @@ class MergeRequest < ApplicationRecord
scope :review_requested_to, ->(user) do
where(
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
)
end
......@@ -389,7 +389,7 @@ class MergeRequest < ApplicationRecord
scope :no_review_requested_to, ->(user) do
where(
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
.not
)
......
......@@ -9,6 +9,8 @@ class RemoveDuplicateLabelsFromProject < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
class BackupLabel < Label
self.inheritance_column = :_type_disabled
self.table_name = 'backup_labels'
end
......
......@@ -12,7 +12,7 @@ module EE
prepended do
scope :latest, -> do
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(
'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