Sha256: 495f593b2f9ac7bc9997e909e0ce01aff68adc4391e08487f0e252a7767599ee

Contents?: true

Size: 626 Bytes

Versions: 66

Compression:

Stored size: 626 Bytes

Contents

module Bmg
  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 Bmg

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
bmg-0.23.3 lib/bmg/sql/processor/flatten.rb
bmg-0.23.2 lib/bmg/sql/processor/flatten.rb
bmg-0.23.1 lib/bmg/sql/processor/flatten.rb
bmg-0.23.0 lib/bmg/sql/processor/flatten.rb
bmg-0.21.5 lib/bmg/sql/processor/flatten.rb
bmg-0.21.4 lib/bmg/sql/processor/flatten.rb
bmg-0.20.5 lib/bmg/sql/processor/flatten.rb
bmg-0.19.3 lib/bmg/sql/processor/flatten.rb
bmg-0.21.3 lib/bmg/sql/processor/flatten.rb
bmg-0.21.2 lib/bmg/sql/processor/flatten.rb
bmg-0.21.0 lib/bmg/sql/processor/flatten.rb
bmg-0.20.4 lib/bmg/sql/processor/flatten.rb
bmg-0.20.2 lib/bmg/sql/processor/flatten.rb
bmg-0.20.1 lib/bmg/sql/processor/flatten.rb
bmg-0.20.0 lib/bmg/sql/processor/flatten.rb
bmg-0.19.2 lib/bmg/sql/processor/flatten.rb
bmg-0.19.1 lib/bmg/sql/processor/flatten.rb
bmg-0.19.0 lib/bmg/sql/processor/flatten.rb
bmg-0.18.15 lib/bmg/sql/processor/flatten.rb
bmg-0.18.14 lib/bmg/sql/processor/flatten.rb