Class: Bmg::Sql::Processor::Where
Constant Summary
UnexpectedError
Instance Attribute Summary
#builder
Instance Method Summary
collapse
#on_set_operator, #on_with_exp
Constructor Details
#initialize(predicate, builder) ⇒ Where
6
7
8
9
|
# File 'lib/bmg/sql/processor/where.rb', line 6
def initialize(predicate, builder)
super(builder)
@predicate = predicate
end
|
Instance Method Details
#on_select_exp(sexpr) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/bmg/sql/processor/where.rb', line 22
def on_select_exp(sexpr)
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
|
#on_union(sexpr) ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/bmg/sql/processor/where.rb', line 11
def on_union(sexpr)
non_falsy = sexpr[2..-1].reject{|expr| falsy?(expr) }
if non_falsy.empty?
apply(sexpr.head_expr)
elsif non_falsy.size == 1
apply(non_falsy.first)
else
[sexpr[0], sexpr[1]] + non_falsy.map{|nf| apply(nf) }
end
end
|