Method: Bmg::Sql::Processor::Where#on_select_exp

Defined in:
lib/bmg/sql/processor/where.rb

#on_select_exp(sexpr) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bmg/sql/processor/where.rb', line 22

def on_select_exp(sexpr)
  if sexpr.group_by_clause || sexpr.has_computed_attributes?
    sexpr = builder.from_self(sexpr)
    call(sexpr)
  else
    pred = @predicate.rename(sexpr.desaliaser(true))
    if sexpr.where_clause
      sexpr_p = Predicate.new(sexpr.where_clause.predicate)
      sexpr.with_update(:where_clause, [ :where_clause, (sexpr_p & pred).sexpr ])
    else
      sexpr.with_insert(4, [ :where_clause, pred.sexpr ])
    end
  end
end