classJoining
final class Joining
Combines the visible relations of the two sides of a join.
Rule: SQLITE-JOIN-001. A LEFT join can extend the rows of its right side with NULLs, a RIGHT join those of everything to its left, a FULL join both; the columns of an extended side can be NULL in the occurrence and keep their declaration. For each column named by USING, or common to both sides of a NATURAL join, the column of the right side is merged into the leftmost column of that name: an unqualified name and the star see the merged column once. Under a RIGHT or FULL join the merged column is the first non-NULL of both, so its type is the choice over both. A USING column that one side certainly lacks is reported. Source: https://sqlite.org/lang_select.html#the_from_clause. Status: Implemented.
Methods§
public function join(
Derivation $derivation,
list<VisibleRelation> $left,
list<VisibleRelation> $right,
JoinStep $step,
): list<VisibleRelation>Joins the relations of a step to the relations to its left.
Parameters
$derivation | Derivation | |
$left | list<VisibleRelation> | The relations to the left, in written order |
$right | list<VisibleRelation> | The relations of the joined term |
$step | JoinStep |
Returns
list<VisibleRelation>Test cases 5
JoiningTest::testJoinCoalescesTheMergedColumnAndExtendsTheLeftSideOfARightJoincallsJoiningTest::testJoinExtendsTheRightSideOfALeftJoincallsJoiningTest::testJoinHidesTheRightUsingColumnAndKeepsTheLeftSidecallsJoiningTest::testJoinMergesEveryCommonNameOfANaturalJoincallsJoiningTest::testJoinReportsAUsingColumnThatAClosedSideLackscalls
Called from 1
Calls 9
- function-call
in_arrayline 49 - method-call Joining::locate() line 49
- method-call Joining::closed() line 60
- method-call Derivation::report() line 61
- new MissingColumn line 61
- method-call Joining::replaced() line 66
- new VisibleRelation line 66
- method-call Joining::coalesced() line 68
- method-call Joining::extend() line 72
public function replaced(
list<VisibleRelation> $relations,
int $position,
VisibleRelation $relation,
): list<VisibleRelation>Answers the relations with the one at a position replaced.
Parameters
$relations | list<VisibleRelation> | |
$position | int | |
$relation | VisibleRelation |
Returns
list<VisibleRelation>Test cases 1
public function coalesced(
VisibleRelation $kept,
int $position,
OutputSlot $other,
): VisibleRelationAnswers a relation whose merged column takes the first non-NULL of its own slot and the slot merged into it.
Parameters
$kept | VisibleRelation | |
$position | int | |
$other | OutputSlot |
Returns
Test cases 1
Called from 1
Calls 5
- new OutputSlot line 98
- method-call Storages::either() line 98
- new Storages line 98
- new VisibleRelation line 101
- new RowShape line 101
public function locate(
list<VisibleRelation> $relations,
string $column,
Derivation $derivation,
): array{int, int}|nullFinds the leftmost column an unqualified name denotes among relations: the relation index and the slot position, or null.
Parameters
$relations | list<VisibleRelation> | |
$column | string | |
$derivation | Derivation |
Returns
array{int, int}|nullTest cases 1
Called from 5
- method-call SqlSemantics\Platform\Sqlite\Rules\Mutation\GeneratedWrites::written() packages/sql-semantics-sqlite/src/Rules/Mutation/GeneratedWrites.php:110
- method-call SqlSemantics\Platform\Sqlite\Rules\Mutation\MutationScope::names() packages/sql-semantics-sqlite/src/Rules/Mutation/MutationScope.php:70
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\Joining::join() packages/sql-semantics-sqlite/src/Rules/Resolution/Joining.php:49
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\Joining::join() packages/sql-semantics-sqlite/src/Rules/Resolution/Joining.php:57
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\Joining::join() packages/sql-semantics-sqlite/src/Rules/Resolution/Joining.php:58
Calls 2
- function-call
in_arrayline 113 - class-const ColumnResolver::QUALIFIED_ONLY() line 113
public function closed(list<VisibleRelation> $relations): boolTells whether every column of the relations is known by name.
Parameters
$relations | list<VisibleRelation> |
Returns
boolTest cases 1
Called from 2
public function extend(list<VisibleRelation> $relations): list<VisibleRelation>Makes every column of the relations able to be NULL in the occurrence, keeping the slot it extends as its origin.
Parameters
$relations | list<VisibleRelation> |
Returns
list<VisibleRelation>Test cases 1
Called from 2
Calls 5
- class-const Nullability::Nullable() line 159
- new OutputSlot line 159
- new ImplicitSlot line 163
- new VisibleRelation line 165
- new RowShape line 165
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
JoiningTest::testClosedIsTrueOnlyForCompleteFullyNamedShapescallsJoiningTest::testCoalescedWidensOneSlotAndLinksItsOrigincallsJoiningTest::testExtendMakesEverySlotAndImplicitNullableAndKeepsOriginscallsJoiningTest::testJoinCoalescesTheMergedColumnAndExtendsTheLeftSideOfARightJoincallsJoiningTest::testJoinExtendsTheRightSideOfALeftJoincallsJoiningTest::testJoinHidesTheRightUsingColumnAndKeepsTheLeftSidecallsJoiningTest::testJoinMergesEveryCommonNameOfANaturalJoincallsJoiningTest::testJoinReportsAUsingColumnThatAClosedSideLackscallsJoiningTest::testLocateFindsTheFirstVisibleSlotByNamecallsJoiningTest::testReplacedSwapsOneRelationByPositioncalls
Relations§
Instantiated in 4
- new SqlSemantics\Platform\Sqlite\Rules\Mutation\GeneratedWrites::written() packages/sql-semantics-sqlite/src/Rules/Mutation/GeneratedWrites.php:110
- new SqlSemantics\Platform\Sqlite\Rules\Mutation\MutationScope::names() packages/sql-semantics-sqlite/src/Rules/Mutation/MutationScope.php:68
- new SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:50
- new SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::enter() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:85
Method calls 5
- method-call SqlSemantics\Platform\Sqlite\Rules\Mutation\GeneratedWrites::written() packages/sql-semantics-sqlite/src/Rules/Mutation/GeneratedWrites.php:110
- method-call SqlSemantics\Platform\Sqlite\Rules\Mutation\MutationScope::names() packages/sql-semantics-sqlite/src/Rules/Mutation/MutationScope.php:70
- method-call SqlSemantics\Platform\Sqlite\Rules\Mutation\MutationScope::names() packages/sql-semantics-sqlite/src/Rules/Mutation/MutationScope.php:76
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:50
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::enter() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:85