Sha256: bb831805fa0b97fd41642fef58d123fc42b219b1a9ac0466c03b27b68cb84ee8

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

module DDQL
  class CoalesceOperator < AggOperator
    def initialize
      super("COALESCE", "Coalesce", return_type: :match)
    end

    def parse(parser, token, expression: nil)
      new_expression = parser.parse(precedence: precedence)
      if expression
        expression = expression.merge(new_expression)
      else
        expression = new_expression
      end

      left_factor, right_factor = expression[:string].split('|', 2)
      {
        op_coalesce: {
          factors: {
            left_factor: {factor: left_factor},
            right_factor: {factor: right_factor},
          },
        }
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddql-1.0.0 lib/ddql/coalesce_operator.rb