Class: Gitlab::SQL::Intersect

Inherits:
SetOperator show all
Defined in:
lib/gitlab/sql/intersect.rb

Overview

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 Method Summary collapse

Methods inherited from SetOperator

#initialize, #operator_keyword_fragment, #to_sql

Constructor Details

This class inherits a constructor from Gitlab::SQL::SetOperator

Class Method Details

.operator_keywordObject


18
19
20
# File 'lib/gitlab/sql/intersect.rb', line 18

def self.operator_keyword
  'INTERSECT'
end