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.



1473
1474
1475
1476
# File 'lib/sequel/sql.rb', line 1473

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

Instance Attribute Details

#join_typeObject (readonly)

The type of join to do



1466
1467
1468
# File 'lib/sequel/sql.rb', line 1466

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.



1470
1471
1472
# File 'lib/sequel/sql.rb', line 1470

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.



1497
1498
1499
1500
1501
# File 'lib/sequel/sql.rb', line 1497

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.



1479
1480
1481
1482
1483
1484
1485
# File 'lib/sequel/sql.rb', line 1479

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.



1489
1490
1491
1492
1493
# File 'lib/sequel/sql.rb', line 1489

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