Module: Bmg::Sql::Join

Includes:
Expr
Included in:
CrossJoin, InnerJoin, LeftJoin
Defined in:
lib/bmg/sql/nodes/join.rb

Constant Summary collapse

JOIN =
"JOIN".freeze
ON =
"ON".freeze

Constants included from Expr

Expr::AND, Expr::AS, Expr::COMMA, Expr::DOT, Expr::EQUAL, Expr::EXISTS, Expr::FALSE, Expr::GREATER, Expr::GREATER_OR_EQUAL, Expr::IN, Expr::LEFT_PARENTHESE, Expr::LESS, Expr::LESS_OR_EQUAL, Expr::NOT, Expr::NOT_EQUAL, Expr::OR, Expr::QUOTE, Expr::RIGHT_PARENTHESE, Expr::SPACE, Expr::TRUE

Instance Method Summary collapse

Methods included from Expr

#each_child, #flatten, #group_by?, #limit_or_offset?, #order_by?, #ordering, #set_operator?, #with_insert, #with_push, #with_update

Instance Method Details

#join?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/bmg/sql/nodes/join.rb', line 13

def join?
  true
end

#leftObject



17
18
19
# File 'lib/bmg/sql/nodes/join.rb', line 17

def left
  self[1]
end

#predicateObject



25
26
27
# File 'lib/bmg/sql/nodes/join.rb', line 25

def predicate
  last
end

#rightObject



21
22
23
# File 'lib/bmg/sql/nodes/join.rb', line 21

def right
  self[2]
end

#to_sql(buffer, dialect) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bmg/sql/nodes/join.rb', line 29

def to_sql(buffer, dialect)
  left.to_sql(buffer, dialect)
  if type.nil?
    buffer << SPACE << JOIN << SPACE
  else
    buffer << SPACE << TYPE << SPACE << JOIN << SPACE
  end
  right.to_sql(buffer, dialect)
  buffer << SPACE << ON << SPACE
  predicate.to_sql(buffer, dialect)
  buffer
end

#typeObject



9
10
11
# File 'lib/bmg/sql/nodes/join.rb', line 9

def type
  nil
end