Class: Bmg::Sql::Processor::Flatten

Inherits:
Bmg::Sql::Processor show all
Defined in:
lib/bmg/sql/processor/flatten.rb

Constant Summary

Constants inherited from Bmg::Sql::Processor

UnexpectedError

Instance Attribute Summary collapse

Attributes inherited from Bmg::Sql::Processor

#builder

Instance Method Summary collapse

Methods inherited from Bmg::Sql::Processor

#initialize, #on_set_operator

Constructor Details

This class inherits a constructor from Bmg::Sql::Processor

Instance Attribute Details

#subqueriesObject (readonly)

Returns the value of attribute subqueries.



10
11
12
# File 'lib/bmg/sql/processor/flatten.rb', line 10

def subqueries
  @subqueries
end

Instance Method Details

#on_table_as(sexpr) ⇒ Object



15
16
17
18
19
# File 'lib/bmg/sql/processor/flatten.rb', line 15

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

#on_with_exp(sexpr) ⇒ Object



6
7
8
9
# File 'lib/bmg/sql/processor/flatten.rb', line 6

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