2018-09-18 11:32:21 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Database
|
|
|
|
module Subquery
|
|
|
|
class << self
|
|
|
|
def self_join(relation)
|
|
|
|
t = relation.arel_table
|
2019-07-16 08:07:42 -04:00
|
|
|
t2 = relation.arel.as('t2')
|
2018-09-18 11:32:21 -04:00
|
|
|
|
|
|
|
relation.unscoped.joins(t.join(t2).on(t[:id].eq(t2[:id])).join_sources.first)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|