Class: Sequel::SQL::JoinClause

Inherits:
Expression show all
Defined in:
lib/sequel/sql.rb

Overview

Represents an SQL JOIN clause, used for joining tables.

Direct Known Subclasses

JoinOnClause, JoinUsingClause

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#==, attr_reader, #clone, #eql?, #hash, inherited, #inspect

Constructor Details

#initialize(join_type, table_expr) ⇒ JoinClause

Create an object with the given join_type and table expression.



1542
1543
1544
1545
1546
# File 'lib/sequel/sql.rb', line 1542

def initialize(join_type, table_expr)
  @join_type = join_type
  @table_expr = table_expr
  freeze
end

Instance Attribute Details

#join_typeObject (readonly)

The type of join to do



1535
1536
1537
# File 'lib/sequel/sql.rb', line 1535

def join_type
  @join_type
end

#table_exprObject (readonly)

The expression representing the table/set related to the JOIN. Is an AliasedExpression if the JOIN uses an alias.



1539
1540
1541
# File 'lib/sequel/sql.rb', line 1539

def table_expr
  @table_expr
end

Instance Method Details

#column_aliasesObject

The column aliases to use for the JOIN , or nil if the JOIN does not use a derived column list.



1567
1568
1569
1570
1571
# File 'lib/sequel/sql.rb', line 1567

def column_aliases
  if @table_expr.is_a?(AliasedExpression)
    @table_expr.columns
  end
end

#tableObject

The table/set related to the JOIN, without any alias.



1549
1550
1551
1552
1553
1554
1555
# File 'lib/sequel/sql.rb', line 1549

def table
  if @table_expr.is_a?(AliasedExpression)
    @table_expr.expression
  else
    @table_expr
  end
end

#table_aliasObject

The table alias to use for the JOIN , or nil if the JOIN does not alias the table.



1559
1560
1561
1562
1563
# File 'lib/sequel/sql.rb', line 1559

def table_alias
  if @table_expr.is_a?(AliasedExpression)
    @table_expr.alias
  end
end