classJoinOperator
final class JoinOperator
implements Node
uses Snapshot
@visibility public.The operator between two terms of a FROM clause: a comma, JOIN, or JOIN after up to three words.
Rule: SQLITE-JOIN-OPERATOR-001. The grammar admits one join keyword and then up to two arbitrary names before JOIN; SQLite accepts the words only when each is a join keyword and the combination is meaningful. A word that is no bare join keyword is kept as the name written. NATURAL merges the common columns; LEFT, RIGHT and FULL select the sides whose rows are extended with NULLs (LEFT and RIGHT together are FULL); INNER or CROSS with an outer keyword, OUTER alone, and any other word are an unknown join type, which SQLite reports and treats as an inner join. Source: https://sqlite.org/lang_select.html#the_from_clause. Status: Implemented.
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 FROM t NATURAL LEFT JOIN u');
$operator = $query->statement->from->steps[0]->operator;
[$operator->natural(), $operator->left(), $operator->right(), $operator->valid()] // => [true, true, false, true]new \SqlSemantics\Platform\Sqlite\Statement\Relation\JoinOperator(true, [\SqlSemantics\Platform\Sqlite\Statement\Relation\JoinKeyword::Left]) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public list<JoinKeyword|Name> $wordspublic bool $comma = falseMethods§
public function __construct(public bool $comma = false, list<JoinKeyword|Name> $words = [])Parameters
$comma | bool | Whether the operator is a comma |
$words | list<JoinKeyword|Name> | The words before JOIN: a join keyword first, then up to two keywords or names |
Throws
InvalidConstruction When the words are not what the grammar admits before JOINCalls 6
- method-call ClosedList::of() line 53
- new ClosedList line 53
- class-const JoinKeyword::class() line 53
- class-const Name::class() line 53
- static-call Check::input() line 54
- function-call
countline 54
public function valid(): boolTells whether every word is a join keyword and the combination is one SQLite accepts.
Returns
boolTest cases 2
Called from 3
- method-call SqlSemantics\Platform\Sqlite\Statement\Relation\JoinOperator::natural() packages/sql-semantics-sqlite/src/Statement/Relation/JoinOperator.php:83
- method-call SqlSemantics\Platform\Sqlite\Statement\Relation\JoinOperator::left() packages/sql-semantics-sqlite/src/Statement/Relation/JoinOperator.php:91
- method-call SqlSemantics\Platform\Sqlite\Statement\Relation\JoinOperator::right() packages/sql-semantics-sqlite/src/Statement/Relation/JoinOperator.php:99
Calls 7
- function-call
in_arrayline 70 - class-const JoinKeyword::Outer() line 70
- class-const JoinKeyword::Left() line 70
- class-const JoinKeyword::Right() line 70
- class-const JoinKeyword::Full() line 70
- class-const JoinKeyword::Inner() line 72
- class-const JoinKeyword::Cross() line 72
public function natural(): boolTells whether the join merges the columns common to both sides.
Returns
boolTest cases 1
Calls 3
- method-call JoinOperator::valid() line 83
- function-call
in_arrayline 83 - class-const JoinKeyword::Natural() line 83
public function left(): boolTells whether the rows of the right side can be extended with NULLs.
Returns
boolTest cases 1
Calls 4
- method-call JoinOperator::valid() line 91
- function-call
in_arrayline 91 - class-const JoinKeyword::Left() line 91
- class-const JoinKeyword::Full() line 91
public function right(): boolTells whether the rows of the left side can be extended with NULLs.
Returns
boolTest cases 1
Calls 4
- method-call JoinOperator::valid() line 99
- function-call
in_arrayline 99 - class-const JoinKeyword::Right() line 99
- class-const JoinKeyword::Full() line 99
public function render(Output $out): voidWrites the operator.
Parameters
$out | Output |
Calls 4
- method-call Output::symbol() line 108
- method-call Output::name() line 114
- class-const NameUse::Label() line 114
- method-call Output::keyword() line 116
Test cases 23§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
JoinOperatorTest::testLeftIsTrueForLeftAndFullJoinscallsJoinOperatorTest::testNaturalIsTrueOnlyForAValidNaturalJoincallsJoinOperatorTest::testRejectsANameAsTheFirstWordcallsJoinOperatorTest::testRejectsMoreThanThreeWordscallsJoinOperatorTest::testRejectsWordsAfterACommacallsJoinOperatorTest::testRightIsTrueForRightAndFullJoinscallsJoinOperatorTest::testValidAcceptsTheCombinationsSqliteKnowscallsJoinOperatorTest::testValidRejectsOuterWithoutASideAndInnerWithOutercalls
Other tests reaching this symbol 15
FromScopeTest::testEnterDerivesEveryOnConditionInTheScopeOfTheWholeChaincallsFromScopeTest::testEnterReportsConstraintsWithoutAJoinAndInvalidOperatorscallsFromScopeTest::testNestedAddsAQualifiedOnlyRelationForAnAliasedJoincallsFromScopeTest::testOpenEntersAChainOrANestedInputAndRecordsItsFactcallsJoiningTest::testJoinCoalescesTheMergedColumnAndExtendsTheLeftSideOfARightJoincallsJoiningTest::testJoinExtendsTheRightSideOfALeftJoincallsJoiningTest::testJoinHidesTheRightUsingColumnAndKeepsTheLeftSidecallsJoiningTest::testJoinMergesEveryCommonNameOfANaturalJoincallsJoiningTest::testJoinReportsAUsingColumnThatAClosedSideLackscallsJoinChainTest::testRejectsAChainAsTheFirstTermcallsJoinChainTest::testRenderWritesTheFirstTermItsConstraintAndEachStepcallsJoinOnTest::testRenderWritesOnBeforeTheConditioncallsJoinStepTest::testRejectsAJoinChainAsTheJoinedRelationcallsJoinStepTest::testRenderWritesOperatorRelationAndConstraintcallsJoinUsingTest::testRenderWritesTheColumnsInParenthesescalls