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.18.13 lib/bmg/sql/processor/flatten.rb
bmg-0.18.12 lib/bmg/sql/processor/flatten.rb
bmg-0.18.11 lib/bmg/sql/processor/flatten.rb
bmg-0.18.10 lib/bmg/sql/processor/flatten.rb
bmg-0.18.9 lib/bmg/sql/processor/flatten.rb
bmg-0.18.8 lib/bmg/sql/processor/flatten.rb
bmg-0.18.7 lib/bmg/sql/processor/flatten.rb
bmg-0.18.6 lib/bmg/sql/processor/flatten.rb
bmg-0.18.5 lib/bmg/sql/processor/flatten.rb
bmg-0.18.4 lib/bmg/sql/processor/flatten.rb
bmg-0.18.3 lib/bmg/sql/processor/flatten.rb
bmg-0.18.2 lib/bmg/sql/processor/flatten.rb
bmg-0.18.1 lib/bmg/sql/processor/flatten.rb
bmg-0.18.0 lib/bmg/sql/processor/flatten.rb
bmg-0.17.8 lib/bmg/sql/processor/flatten.rb
bmg-0.17.7 lib/bmg/sql/processor/flatten.rb
bmg-0.17.6 lib/bmg/sql/processor/flatten.rb
bmg-0.17.5 lib/bmg/sql/processor/flatten.rb
bmg-0.17.4 lib/bmg/sql/processor/flatten.rb
bmg-0.17.3 lib/bmg/sql/processor/flatten.rb