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, #eql?, #hash, inherited, #inspect, #lit, #sql_literal

Constructor Details

#initialize(join_type, table_expr) ⇒ JoinClause

Create an object with the given join_type and table expression.



1512
1513
1514
1515
1516
# File 'lib/sequel/sql.rb', line 1512

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

Instance Attribute Details

#join_type ⇒ Object (readonly)

The type of join to do



1505
1506
1507
# File 'lib/sequel/sql.rb', line 1505

def join_type
  @join_type
end

#table_expr ⇒ Object (readonly)

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



1509
1510
1511
# File 'lib/sequel/sql.rb', line 1509

def table_expr
  @table_expr
end

Instance Method Details

#column_aliases ⇒ Object

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



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

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

#table ⇒ Object

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



1519
1520
1521
1522
1523
1524
1525
# File 'lib/sequel/sql.rb', line 1519

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

#table_alias ⇒ Object

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



1529
1530
1531
1532
1533
# File 'lib/sequel/sql.rb', line 1529

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