Sha256: b4c17d6c790f621b05d192dbf1f8e002d962c2ef9c43bd7fc8a6a995e4fc27b8

Contents?: true

Size: 456 Bytes

Versions: 2

Compression:

Stored size: 456 Bytes

Contents

require_relative 'pass_thru'

module ConceptQL
  module Nodes
    class Count < PassThru
      def query(db)
        db.from(unioned(db))
          .group(*COLUMNS)
          .select(*(COLUMNS - [:value_as_numeric]))
          .select_append{count(1).as(:value_as_numeric)}
          .from_self
      end

      def unioned(db)
        children.map { |c| c.evaluate(db) }.inject do |uni, q|
          uni.union(q)
        end
      end
    end
  end
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
conceptql-0.1.1 lib/conceptql/nodes/count.rb
conceptql-0.1.0 lib/conceptql/nodes/count.rb