classJoinChain
final class JoinChain
implements Relation
uses Snapshot
@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.
$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]$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\InvalidConstructionProperties§
public list<JoinStep> $stepspublic Relation $firstMethods§
public function __construct(
public Relation $first,
list<JoinStep> $steps,
public JoinOn|JoinUsing|null $constraint = null,
)Parameters
Calls 3
- static-call Check::listOf() line 56
- class-const JoinStep::class() line 56
- static-call Check::input() line 57
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives the terms, the constraints and the shape of the joined rows.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call FromScope::enter() line 66
- new FromScope line 66
public function render(Output $out): voidTest cases 29§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
JoinChainTest::testDeriveRelationListsCommaSeparatedTablesSideBySidecallsJoinChainTest::testDeriveRelationReportsAConstraintWrittenWithoutAJoincallsJoinChainTest::testDeriveRelationShowsAMergedColumnOncecallsJoinChainTest::testRejectsAChainAsTheFirstTermcallsJoinChainTest::testRejectsASingleTermWithoutAConstraintcallsJoinChainTest::testRenderWritesTheFirstTermItsConstraintAndEachStepcalls
Other tests reaching this symbol 23
FromRuleTest::testConstraintLowersOnUsingAndNonecallsFromRuleTest::testIndexedLowersIndexedByAndNotIndexedcallsFromRuleTest::testOperatorLowersTheCommaTheBareJoinAndTheKeywordJoinscallsFromRuleTest::testTermLowersEachKindOfTermWithItsAliascallsFromRuleTest::testTermsAnswersOneTermWithoutAConstraintAndAChainOtherwisecallsFromRuleTest::testWordLowersAWordBeforeJoinAsAKeywordWhenWrittenAsOneAndAsANameOtherwisecallsOperationTest::testInputRelationIsTheFromStructureOfASelectioncallsConditionalColumnTest::testCandidatesKeepAKnownSlotWhileANearerOccurrenceIsUnknowncallsRelationTest::testDeriveRelationGivesEachOccurrenceOfOneTableItsOwnFactcallsFromScopeTest::testEnterDerivesEveryOnConditionInTheScopeOfTheWholeChaincallsFromScopeTest::testEnterReportsConstraintsWithoutAJoinAndInvalidOperatorscallsFromScopeTest::testNestedAddsAQualifiedOnlyRelationForAnAliasedJoincallsFromScopeTest::testOpenEntersAChainOrANestedInputAndRecordsItsFactcallsJoinKeywordTest::testCasesAreReadFromTheWordsBeforeJoinWhateverTheirSpellingcallsJoinOnTest::testConditionSeesBothSidesOfTheJoincallsJoinOnTest::testRenderWritesOnBeforeTheConditioncallsJoinOperatorTest::testRenderWritesACommaOrTheWordsBeforeJoincallsJoinStepTest::testRejectsAJoinChainAsTheJoinedRelationcallsJoinStepTest::testRenderWritesOperatorRelationAndConstraintcallsJoinUsingTest::testColumnsResolveToTheLeftSideUnlessQualifiedcallsJoinUsingTest::testRenderWritesTheColumnsInParenthesescallsNestedInputTest::testDeriveRelationExposesTheJoinWrittenInParenthesescallsTableCallTest::testDeriveRelationResolvesArgumentsAgainstTheTablesToTheLeftcalls