Class: Seaquel::Statement::Join

Inherits:
Object
  • Object
show all
Defined in:
lib/seaquel/statement/join.rb

Overview

A join clause inside an SQL statement.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tables) ⇒ Join

Returns a new instance of Join.



10
11
12
13
14
# File 'lib/seaquel/statement/join.rb', line 10

def initialize tables
  @tables = AST::List.new(tables)

  @ons = AST::JoinOp.new(:and, [])
end

Instance Attribute Details

#onsObject (readonly)

Returns the value of attribute ons.



8
9
10
# File 'lib/seaquel/statement/join.rb', line 8

def ons
  @ons
end

#tablesObject (readonly)

Returns the value of attribute tables.



7
8
9
# File 'lib/seaquel/statement/join.rb', line 7

def tables
  @tables
end

Instance Method Details

#convert(conversion_helper) ⇒ String

Turns a join statement into SQL by invoking conversion_helper on the right parts.

Parameters:

  • conversion_helper (#convert)

    instance of a class that implements a #convert method that turns expressions into SQL.

Returns:

  • (String)

    SQL string for this join



27
28
29
30
31
32
33
# File 'lib/seaquel/statement/join.rb', line 27

def convert conversion_helper
  parts = []
  parts << 'INNER JOIN'
  parts << conversion_helper.convert(tables)
  parts << 'ON'
  parts << conversion_helper.convert(ons)
end

#on(exps) ⇒ Object



16
17
18
# File 'lib/seaquel/statement/join.rb', line 16

def on exps
  ons.concat(*exps)
end