The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Class::ReluctantORM::SQL::From::Join - Represent a JOIN in a SQL statement

SYNOPSIS

  use Class::ReluctantORM::SQL::Aliases;

  # Make three kinds of joins
  my $join1 = Join->new('INNER', $left_rel, $right_rel, $criterion);
  my $join2 = Join->new('LEFT OUTER', $left_rel, $right_rel, $criterion);
  my $join3 = Join->new('CROSS', $left_rel, $right_rel, $criterion);

  # Make a tree of joins - (a INNER JOIN b) INNER JOIN c
  my $join4 = Join->new('INNER', $table_a, $table_b, $criterion);
  my $join5 = Join->new('INNER', $join4, $table_c, $criterion);

  # Use it in a FROM clause
  my $from = From->new($join5);

DESCRIPTION

Represents a JOIN in a SQL statement. Inherits from Class::ReluctantORM::SQL::From::Relation .

Each JOIN has two children, a left relation and a right relation. In addition, there is a Criterion that represents the join condition, and a type that represents the JOIN type.

RIGHT OUTER joins are not supported. Transform them into LEFT OUTERs.

NATURAL joins are not supported, because the Criterion must be explicit.

CONSTRUCTORS

$join = Join->new($type, $left_rel, $right_rel, $crit, [$relationship]);

Creates a new Join.

$type must be one of INNER, LEFT OUTER, or CROSS.

$left_rel and $right_rel are Relation subclasses (this includes Tables, Joins, and SubQueries).

$crit is a Criterion specifying the join condition(s).

$relationship is an optional Relationship. This is used as a hint when resolving ambiguities in the SQL, and is optional.

$clone = $join->clone();

Makes a deep copy of the Join object. All SQL objects are clone()'d, but annotations (such as Relationships) are not.

ACCESSORS AND MUTATORS

$join->alias(...);

$join->has_column(...);

$join->columns(...);

$join->tables();

$join->knows_any_columns(...);

$join->knows_all_columns(...);

$join->pretty_print(...);

These methods are inherited from Relation.

@rel = $join->child_relations();

Returns a two-element array with the left and right relations. Required by the Relation interface.

$join->criterion($crit);

$crit = $join->criterion();

Reads or sets the join condition as a Class::ReluctantORM::SQL::Where::Criterion .

$bool = $join->is_leaf_relation();

Always returns false for this class. Required by the Relation interface.

$bool = $rel->is_join();

All objects of this class return true. The class adds this method to its parent class, making all other subclasses of return false.

$join->left_relation($rel);

$rel = $join->left_relation();

Reads or sets the left-hand relation of the join condition a Class::ReluctantORM::SQL::From::Relation .

$r = $join->relationship();

$join->relationship($relationship);

Reads or sets auxiliary relationship data, a Class::ReluctantORM::Relationship.

$join->right_relation($rel);

$rel = $join->right_relation();

Reads or sets the right-hand relation of the join condition a Class::ReluctantORM::SQL::From::Relation .

$join->type($type);

$type = $join->type();

Reads or sets the join type - one of INNER, LEFT OUTER, or CROSS.

AUTHOR

Clinton Wolfe