Module: Alf::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



56
57
58
59
60
61
# File 'lib/alf/sql/nodes/expr.rb', line 56

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

#join?Boolean

Returns:

  • (Boolean)


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

def join?
  false
end

#limit_or_offset?Boolean

Returns:

  • (Boolean)


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

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

#orderingObject



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

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

#set_operator?Boolean

Returns:

  • (Boolean)


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

def set_operator?
  false
end

#with_insert(index, what) ⇒ Object



48
49
50
# File 'lib/alf/sql/nodes/expr.rb', line 48

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

#with_push(*sexprs) ⇒ Object



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

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

#with_update(index, what) ⇒ Object



43
44
45
46
# File 'lib/alf/sql/nodes/expr.rb', line 43

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