summaryrefslogtreecommitdiff
path: root/lib/gitlab/sql/intersect.rb
blob: c661db3d4c5e6037725cc5a106c890ddbd4f4def (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module Gitlab
  module SQL
    # Class for building SQL INTERSECT statements.
    #
    # ORDER BYs are dropped from the relations as the final sort order is not
    # guaranteed any way.
    #
    # Example usage:
    #
    #     hierarchies = [group1.self_and_hierarchy, group2.self_and_hierarchy]
    #     intersect   = Gitlab::SQL::Intersect.new(hierarchies)
    #     sql         = intersect.to_sql
    #
    #     Project.where("id IN (#{sql})")
    class Intersect < SetOperator
      def self.operator_keyword
        'INTERSECT'
      end
    end
  end
end