Module: Bmg::Sql::Expr

Constant Summary collapse

LEFT_PARENTHESE =
"(".freeze
RIGHT_PARENTHESE =
")".freeze
SPACE =
" ".freeze
COMMA =
",".freeze
DOT =
".".freeze
QUOTE =
"'".freeze
AS =
"AS".freeze
AND =
"AND".freeze
OR =
"OR".freeze
NOT =
"NOT".freeze
TRUE =
"TRUE".freeze
FALSE =
"FALSE".freeze
EQUAL =
"=".freeze
NOT_EQUAL =
"<>".freeze
GREATER =
">".freeze
LESS =
"<".freeze
GREATER_OR_EQUAL =
">=".freeze
LESS_OR_EQUAL =
"<=".freeze
IN =
"IN".freeze
EXISTS =
"EXISTS".freeze

Instance Method Summary collapse

Instance Method Details

#each_child(skip = 0) ⇒ Object



64
65
66
67
68
69
# File 'lib/bmg/sql/nodes/expr.rb', line 64

def each_child(skip = 0)
  each_with_index do |c,i|
    next if i <= skip
    yield(c, i - 1)
  end
end

#flattenObject



71
72
73
# File 'lib/bmg/sql/nodes/expr.rb', line 71

def flatten
  Processor::Flatten.new(nil).call(self)
end

#group_by?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/bmg/sql/nodes/expr.rb', line 38

def group_by?
  not(group_by_clause.nil?)
end

#join?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/bmg/sql/nodes/expr.rb', line 34

def join?
  false
end

#limit_or_offset?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/bmg/sql/nodes/expr.rb', line 30

def limit_or_offset?
  not(limit_clause.nil? and offset_clause.nil?)
end

#order_by?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/bmg/sql/nodes/expr.rb', line 42

def order_by?
  not(order_by_clause.nil?)
end

#orderingObject



46
47
48
49
# File 'lib/bmg/sql/nodes/expr.rb', line 46

def ordering
  obc = order_by_clause
  obc && order_by_clause.to_ordering
end

#set_operator?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/bmg/sql/nodes/expr.rb', line 26

def set_operator?
  false
end

#with_insert(index, what) ⇒ Object



56
57
58
# File 'lib/bmg/sql/nodes/expr.rb', line 56

def with_insert(index, what)
  dup.tap{|x| x.insert(index, Grammar.sexpr(what)) }
end

#with_push(*sexprs) ⇒ Object



60
61
62
# File 'lib/bmg/sql/nodes/expr.rb', line 60

def with_push(*sexprs)
  dup.push(*sexprs)
end

#with_update(index, what) ⇒ Object



51
52
53
54
# File 'lib/bmg/sql/nodes/expr.rb', line 51

def with_update(index, what)
  index = find_child_index(index) if index.is_a?(Symbol)
  dup.tap{|x| x[index] = Grammar.sexpr(what) }
end