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

order_by_column_data.rb « 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: 9cb1ba1542dd55c19ee1bfd1bca8d138c356bc1e (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
# frozen_string_literal: true

module Gitlab
  module Pagination
    module Keyset
      module InOperatorOptimization
        class OrderByColumnData < ColumnData
          extend ::Gitlab::Utils::Override

          attr_reader :column

          # column - a ColumnOrderDefinition object
          # as - custom alias for the column
          # arel_table - relation where the column is located
          def initialize(column, as, arel_table)
            super(column.attribute_name.to_s, as, arel_table)
            @column = column
          end

          override :arel_column
          def arel_column
            column.column_expression
          end

          override :column_expression
          def column_expression
            arel_table[original_column_name]
          end

          def column_for_projection
            column.column_expression.as(original_column_name)
          end
        end
      end
    end
  end
end