Method: Select#on

Defined in:
lib/select.rb

#on(&block) ⇒ Object

call-seq: sql_statement.on { block } -> a_sql_statement

Creates a new OnWhereBuilder instance, passing the block as a parameter, then executes to_sql on the OnWhereBuilder instance. The resulting string from the OnWhereBuilder instance is appended to the SQL statement. Returns self.

Select.all.from[:table1].inner_join[:table2].on { equal :table1.column1, :table2.column1 }.to_sql
  #=> "select * from table1 inner join table2 on table1.column1 = table2.column2"


124
125
126
127
# File 'lib/select.rb', line 124

def on(&block)
  @to_sql += OnWhereBuilder.new(self.tables, &block).to_sql
  self
end