Class: OracleSqlParser::Ast::Subquery

Inherits:
Hash show all
Defined in:
lib/oracle-sql-parser/ast/subquery.rb

Instance Method Summary collapse

Methods inherited from Hash

[], #[]=, #initialize, #inspect, #map_ast!, #method_missing, #remove_nil_values!

Methods inherited from Base

#==, [], #ast, #deep_dup, deep_dup, find_different_value, #initialize, #initialize_copy, #inspect, #map_ast, #map_ast!, #remove_nil_values!

Methods included from Util::Parameterizable

#to_parameterized, #to_parameternized

Constructor Details

This class inherits a constructor from OracleSqlParser::Ast::Hash

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OracleSqlParser::Ast::Hash

Instance Method Details

#order_by_clause=(value) ⇒ Object



19
20
21
# File 'lib/oracle-sql-parser/ast/subquery.rb', line 19

def order_by_clause=(value)
  @ast[:order_by_clause] = value
end

#to_sql(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/oracle-sql-parser/ast/subquery.rb', line 3

def to_sql(options = {})
  if @ast[:union]
    [
      @ast[:query_block1],
      @ast[:union].map(&:to_sql).join(' '),
      @ast[:query_block2],
      @ast[:order_by_clause],
    ].compact.map(&:to_sql).join(' ')
  else
    [
      @ast[:query_block],
      @ast[:order_by_clause]
    ].compact.map(&:to_sql).join(' ')
  end
end