Sha256: c45d29e52b4b201f126180d75fbe7e335bf11e273c77f7af91cf3a34747e20b7

Contents?: true

Size: 626 Bytes

Versions: 5

Compression:

Stored size: 626 Bytes

Contents

module Alf
  module Sql
    class Processor
      class Flatten < Processor

        def on_with_exp(sexpr)
          @subqueries = sexpr.with_spec.to_hash
          apply(sexpr.select_exp)
        end
        attr_reader :subqueries

        alias :on_select_exp :copy_and_apply
        alias :on_missing    :copy_and_apply

        def on_table_as(sexpr)
          return sexpr unless subqueries
          return sexpr unless subquery = subqueries[sexpr.table_name]
          [ :subquery_as, apply(subquery), sexpr.right ]
        end

      end # class Flatten
    end # class Processor
  end # module Sql
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-sql-0.16.3 lib/alf/sql/processor/flatten.rb
alf-sql-0.16.2 lib/alf/sql/processor/flatten.rb
alf-sql-0.16.1 lib/alf/sql/processor/flatten.rb
alf-sql-0.16.0 lib/alf/sql/processor/flatten.rb
alf-sql-0.15.0 lib/alf/sql/processor/flatten.rb