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

The terms of a FROM clause joined from left to right.

A chain is a first term and the further terms in written order, each with the operator before it and the constraint after it; SQLite joins them left to right. The grammar also admits a constraint after the first term, which SQLite rejects.

Rule: SQLITE-JOIN-CHAIN-001. The terms are derived from left to right and combined by SQLITE-JOIN-001; every ON condition sees all relations of the chain. The shape of the chain is the row that * selects: every column of every term except the merged columns of USING and NATURAL joins. An unknown join type and a constraint without a join are reported. Terminates: the terms are a finite list walked in a loop. Source: https://sqlite.org/lang_select.html#the_from_clause. Status: Implemented.

Reading the terms of a join chaindoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 FROM t JOIN u ON t.a = u.a, v');
    [$query->statement->from->first->name->name->value, count($query->statement->from->steps), $query->statement->from->steps[1]->operator->comma] // => ['t', 2, true]
Refusing a chain that joins nothing and constrains nothingdoctest
$table = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 FROM t')->statement->from;
    new \SqlSemantics\Platform\Sqlite\Statement\Relation\JoinChain($table, []) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public list<JoinStep> $steps
public Relation $first
public JoinOn|JoinUsing|null $constraint = null

Methods§

public function __construct(
    public Relation $first,
    list<JoinStep> $steps,
    public JoinOn|JoinUsing|null $constraint = null,
)

Parameters

$firstRelationThe first term
$stepslist<JoinStep>The further terms in written order
$constraintJoinOn|JoinUsing|nullThe constraint written after the first term
Calls 3
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Derives the terms, the constraints and the shape of the joined rows.

Parameters

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

Writes the terms in order.

Parameters

$outOutput
Calls 1

Test cases 29§

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

Dedicated tests 6
Other tests reaching this symbol 23

Relations§

Instantiated in 1
Type checks 2
Type declarations 1