classJoin
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.
$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']$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\InvalidConstructionProperties§
public Relation $leftpublic JoinKind $kindpublic Relation $rightpublic bool $natural = falseMethods§
public function __construct(
public Relation $left,
public JoinKind $kind,
public Relation $right,
public JoinOn|JoinUsing|null $condition = null,
public bool $natural = false,
)Parameters
Calls 2
- static-call Check::input() line 53
- class-const JoinKind::Cross() line 54
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives both sides, the condition and the joined columns.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call FromScope::enter() line 65
- new FromScope line 65
public function render(Output $out): voidWrites the sides around NATURAL, the join kind and JOIN, then the condition.
Parameters
$out | Output |
Calls 3
- method-call Output::node() line 73
- method-call Output::keyword() line 75
- method-call JoinKind::keywords() line 77
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
JoinTestcalls
Other tests reaching this symbol 2
Relations§
Instantiated in 5
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\FromRule::joined() packages/sql-semantics-postgres/src/Lowering/Query/FromRule.php:178
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\FromRule::joined() packages/sql-semantics-postgres/src/Lowering/Query/FromRule.php:179
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\FromRule::joined() packages/sql-semantics-postgres/src/Lowering/Query/FromRule.php:180
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\FromRule::joined() packages/sql-semantics-postgres/src/Lowering/Query/FromRule.php:181
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\FromRule::joined() packages/sql-semantics-postgres/src/Lowering/Query/FromRule.php:182
Type checks 4
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Locking::refused() packages/sql-semantics-postgres/src/Rules/Query/Locking.php:139
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Locking::tables() packages/sql-semantics-postgres/src/Rules/Query/Locking.php:158
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Trailing::relation() packages/sql-semantics-postgres/src/Rules/Query/Trailing.php:134
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::open() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:55
Type declarations 5
- type SqlSemantics\Platform\PostgreSql\Lowering\Query\FromRule packages/sql-semantics-postgres/src/Lowering/Query/FromRule.php:172
- type SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:92
- type SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:50
- type SqlSemantics\Platform\PostgreSql\Rules\Resolution\Joining packages/sql-semantics-postgres/src/Rules/Resolution/Joining.php:103
- type SqlSemantics\Platform\PostgreSql\Statement\Relation\ParenthesizedJoin packages/sql-semantics-postgres/src/Statement/Relation/ParenthesizedJoin.php:45