final class Join
    implements Relation
    uses Snapshot
Public API: explicitly declared with @visibility public.

A join of two FROM items.

Mirrors PostgreSQL's JoinExpr without alias. A CROSS join has no condition, a NATURAL join merges the columns both sides share, every other join has an ON or USING condition. Joins associate from the left; a join on the right of a CROSS or NATURAL join needs parentheses, so such an operand is refused. The facts follow PG-JOIN-001. Source: https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-JOIN. Status: Implemented.

Reading a joindoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1 FROM a NATURAL LEFT OUTER JOIN b');
    [$query->statement->from->kind->value, $query->statement->from->natural, $query->toString()] // => ['LEFT', true, 'SELECT 1 FROM a NATURAL LEFT JOIN b']
Refusing a qualified join without a conditiondoctest
$a = new \SqlSemantics\Platform\PostgreSql\Statement\Relation\TableInput(new \SqlSemantics\Platform\PostgreSql\Statement\Name\RelationReference(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('a'))));
    $b = new \SqlSemantics\Platform\PostgreSql\Statement\Relation\TableInput(new \SqlSemantics\Platform\PostgreSql\Statement\Name\RelationReference(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('b'))));
    new \SqlSemantics\Platform\PostgreSql\Statement\Relation\Join($a, \SqlSemantics\Platform\PostgreSql\Statement\Relation\JoinKind::Left, $b) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public Relation $left
public JoinKind $kind
public Relation $right
public JoinOn|JoinUsing|null $condition = null
public bool $natural = false

Methods§

public function __construct(
    public Relation $left,
    public JoinKind $kind,
    public Relation $right,
    public JoinOn|JoinUsing|null $condition = null,
    public bool $natural = false,
)

Parameters

$leftRelationThe left side
$kindJoinKindThe kind of join
$rightRelationThe right side
$conditionJoinOn|JoinUsing|nullThe join condition
$naturalboolWhether NATURAL is written
Calls 2
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Derives both sides, the condition and the joined columns.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes the sides around NATURAL, the join kind and JOIN, then the condition.

Parameters

$outOutput
Calls 3

Test cases 3§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Instantiated in 5
Type checks 4
Type declarations 5