classJoinedTable
final class JoinedTable
implements Relation
uses Snapshot
@visibility public.A join of two table references with its ON condition or USING column list.
The structure follows the parse of the release, where a join can nest on the right without parentheses (t JOIN u JOIN v ON c joins t to the join of u and v in 8.0 and later). A natural join takes no condition and its right operand is no unparenthesized join; LEFT and RIGHT joins require a condition; a comma list as an operand is written in parentheses.
Rule: MYSQL-JOIN-001. The operands and the condition are derived by MYSQL-FROM-SCOPE-001 and combined by MYSQL-JOIN-COLUMNS-001. Source: https://dev.mysql.com/doc/refman/8.4/en/join.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT 1 FROM t LEFT JOIN u USING (a)');
[$query->statement->from->operator, $query->statement->from->using[0]->value] // => [\SqlSemantics\Platform\MySql\Statement\Relation\Join\JoinOperator::Left, 'a']$t = new \SqlSemantics\Platform\MySql\Statement\Relation\TableReference(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('t')));
$u = new \SqlSemantics\Platform\MySql\Statement\Relation\TableReference(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('u')));
new \SqlSemantics\Platform\MySql\Statement\Relation\JoinedTable($t, \SqlSemantics\Platform\MySql\Statement\Relation\Join\JoinOperator::Left, $u) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstructionProperties§
public list<Name> $usingpublic Relation $leftpublic JoinOperator $operatorpublic Relation $rightpublic Scalar|null $on = nullMethods§
public function __construct(
public Relation $left,
public JoinOperator $operator,
public Relation $right,
public Scalar|null $on = null,
list<Name> $using = [],
)Parameters
$left | Relation | The left operand |
$operator | JoinOperator | The join operator |
$right | Relation | The right operand |
$on | Scalar|null | The ON condition |
$using | list<Name> | The USING columns |
Calls 5
- static-call Check::listOf() line 60
- class-const Name::class() line 60
- static-call Check::input() line 61
- method-call JoinOperator::natural() line 62
- method-call JoinOperator::conditioned() line 63
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives the operands, the condition and the shape of the joined rows.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call FromScope::enter() line 73
- new FromScope line 73
public function render(Output $out): voidWrites the operands, the operator and the condition.
Parameters
$out | Output |
Calls 6
- method-call Output::node() line 81
- method-call JoinOperator::keywords() line 81
- method-call Output::keyword() line 83
- method-call Output::symbol() line 89
- method-call Output::name() line 91
- class-const NameUse::Column() line 91
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
JoinedTableTest::testACommaListAsAnOperandIsRejectedcallsJoinedTableTest::testAConditionOnANaturalJoinIsRejectedcallsJoinedTableTest::testAJoinOnTheRightOfANaturalJoinIsRejectedcallsJoinedTableTest::testBothConditionsAreRejectedcallsJoinedTableTest::testDeriveRelationNestsLikeTheParseOfTheReleasecalls
Other tests reaching this symbol 3
Relations§
Instantiated in 2
Type checks 3
- instanceof SqlSemantics\Platform\MySql\Rules\Dml\SourceRelations::members() packages/sql-semantics-mysql/src/Rules/Dml/SourceRelations.php:79
- instanceof SqlSemantics\Platform\MySql\Rules\Query\From\FromScope::open() packages/sql-semantics-mysql/src/Rules/Query/From/FromScope.php:53
- instanceof SqlSemantics\Platform\MySql\Rules\Query\From\FromScope::enter() packages/sql-semantics-mysql/src/Rules/Query/From/FromScope.php:97
Type declarations 7
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\JoinRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/JoinRule.php:127
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\JoinRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/JoinRule.php:154
- type SqlSemantics\Platform\MySql\Lowering\Query\Modern\ReferenceRule packages/sql-semantics-mysql/src/Lowering/Query/Modern/ReferenceRule.php:92
- type SqlSemantics\Platform\MySql\Lowering\Query\Modern\ReferenceRule packages/sql-semantics-mysql/src/Lowering/Query/Modern/ReferenceRule.php:119
- type SqlSemantics\Platform\MySql\Rules\Query\From\FromScope packages/sql-semantics-mysql/src/Rules/Query/From/FromScope.php:81
- type SqlSemantics\Platform\MySql\Rules\Query\From\Joining packages/sql-semantics-mysql/src/Rules/Query/From/Joining.php:47
- type SqlSemantics\Platform\MySql\Rules\Query\From\Joining packages/sql-semantics-mysql/src/Rules/Query/From/Joining.php:87