Welcome to mirror list, hosted at ThFree Co, Russian Federation.

as_with_materialized.rb « database « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a6a7e7455e90752d25d8c00a87fd1249b4533167 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

module Gitlab
  module Database
    # This class is a special Arel node which allows optionally define the `MATERIALIZED` keyword for CTE and Recursive CTE queries.
    class AsWithMaterialized < Arel::Nodes::As
      MATERIALIZED = 'MATERIALIZED '

      def initialize(left, right, materialized: true)
        if materialized
          right.prepend(MATERIALIZED)
        end

        super(left, right)
      end
    end
  end
end