Class: Bmg::Sql::Processor::Requalify

Inherits:
Bmg::Sql::Processor show all
Defined in:
lib/bmg/sql/processor/requalify.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

#on_set_operator, #on_with_exp

Constructor Details

#initialize(builder) ⇒ Requalify

Returns a new instance of Requalify.



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

def initialize(builder)
  super
  @requalify = Hash.new{|h,k|
    h[k.to_s] = builder.next_qualifier!
  }
end

Instance Attribute Details

#requalifyObject (readonly)

Returns the value of attribute requalify.



12
13
14
# File 'lib/bmg/sql/processor/requalify.rb', line 12

def requalify
  @requalify
end

Instance Method Details

#on_qualified_identifier(sexpr) ⇒ Object



26
27
28
# File 'lib/bmg/sql/processor/requalify.rb', line 26

def on_qualified_identifier(sexpr)
  Predicate::Factory.qualified_identifier(requalify[sexpr.qualifier.to_s].to_sym, sexpr.name.to_sym)
end

#on_range_var_name(sexpr) ⇒ Object



17
18
19
# File 'lib/bmg/sql/processor/requalify.rb', line 17

def on_range_var_name(sexpr)
  Grammar.sexpr [:range_var_name, requalify[sexpr.qualifier.to_s] ]
end

#on_where_clause(sexpr) ⇒ Object



21
22
23
24
# File 'lib/bmg/sql/processor/requalify.rb', line 21

def on_where_clause(sexpr)
  pred = Predicate::Grammar.sexpr(apply(sexpr.predicate))
  sexpr([:where_clause, pred])
end