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

order_values_loader_strategy.rb « strategies « in_operator_optimization « keyset « pagination « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fc2b56048f6c90e86ab0143affa31b8d5fe29c45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

module Gitlab
  module Pagination
    module Keyset
      module InOperatorOptimization
        module Strategies
          class OrderValuesLoaderStrategy
            def initialize(model, order_by_columns)
              @model = model
              @order_by_columns = order_by_columns
            end

            def initializer_columns
              order_by_columns.map do |column|
                column_name = column.original_column_name.to_s
                type = model.columns_hash[column_name].sql_type
                "NULL::#{type} AS #{column_name}"
              end
            end

            def columns
              order_by_columns.array_lookup_expressions_by_position(QueryBuilder::RECURSIVE_CTE_NAME)
            end

            def final_projections
              order_by_columns.map(&:original_column_name)
            end

            private

            attr_reader :model, :order_by_columns
          end
        end
      end
    end
  end
end