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.



1432
1433
1434
1435
# File 'lib/sequel/sql.rb', line 1432

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



1425
1426
1427
# File 'lib/sequel/sql.rb', line 1425

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.



1429
1430
1431
# File 'lib/sequel/sql.rb', line 1429

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.



1456
1457
1458
1459
1460
# File 'lib/sequel/sql.rb', line 1456

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.



1438
1439
1440
1441
1442
1443
1444
# File 'lib/sequel/sql.rb', line 1438

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.



1448
1449
1450
1451
1452
# File 'lib/sequel/sql.rb', line 1448

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