classFromScope
final class FromScope
Derives the input relations of a FROM clause and the relations they make visible to names.
Rule: SQLITE-FROM-SCOPE-001. A table, a table-valued function and a derived query are each one visible relation under their correlation name, or under their table name when they have none. The arguments of a table-valued function see the relations to its left; a derived query sees none of its siblings. A chain combines its terms from left to right by SQLITE-JOIN-001 and derives every ON condition where all its relations are visible. Parentheses around several terms keep the relations inside visible and add their correlation name for the joined row; parentheses around one term replace its correlation name with their own, except that plain parentheses at the very start of a FROM clause change nothing. Terminates: chains are walked in a loop; recursion follows parentheses. Source: https://sqlite.org/lang_select.html#the_from_clause. Status: Implemented.
Methods§
public function open(
Relation $term,
Derivation $derivation,
Environment $outer,
list<VisibleRelation> $left = [],
bool $leading = true,
): JoinedInputDerives one term, records its facts and answers what it makes visible.
Parameters
$term | Relation | |
$derivation | Derivation | |
$outer | Environment | |
$left | list<VisibleRelation> | The relations to the left of the term in its chain |
$leading | bool | Whether the term starts a FROM clause and carries no constraint |
Returns
Test cases 3
Called from 5
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:47
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::enter() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:76
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::enter() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:78
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::nested() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:111
- method-call SqlSemantics\Platform\Sqlite\Statement\Mutation\Update::deriveWithin() packages/sql-semantics-sqlite/src/Statement/Mutation/Update.php:107
Calls 10
- method-call FromScope::enter() line 54
- method-call Derivation::target() line 55
- method-call Derivation::relation() line 59
- new Environment line 59
- method-call Relation::alias() line 61
- new JoinedInput line 63
- new VisibleRelation line 63
- method-call Relation::name() line 63
- method-call TableShapes::implicit() line 63
- new TableShapes line 63
public function enter(
JoinChain|NestedInput $node,
Derivation $derivation,
Environment $outer,
list<VisibleRelation> $left,
bool $leading,
): JoinedInputDerives the terms of a chain or of parentheses without recording the facts of the node itself.
Parameters
$node | JoinChain|NestedInput | |
$derivation | Derivation | |
$outer | Environment | |
$left | list<VisibleRelation> | The relations to the left of the node in its chain |
$leading | bool |
Returns
Test cases 2
Called from 3
- method-call SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::open() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:54
- method-call SqlSemantics\Platform\Sqlite\Statement\Relation\JoinChain::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Relation/JoinChain.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Relation\NestedInput::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Relation/NestedInput.php:53
Calls 18
- method-call FromScope::nested() line 74
- method-call FromScope::open() line 76
- method-call Derivation::report() line 80
- new Misuse line 80
- class-const MisuseRule::UnknownJoinType() line 80
- class-const MisuseRule::NaturalJoinWithConstraint() line 83
- method-call Joining::join() line 85
- new Joining line 85
- new Environment line 87
- class-const MisuseRule::OnWithoutJoin() line 89
- class-const MisuseRule::UsingWithoutJoin() line 89
- function-call
array_mapline 91 - method-call RowValueUse::single() line 93
- new RowValueUse line 93
- method-call Derivation::scalar() line 93
- new JoinedInput line 97
- new RelationFact line 97
- method-call FromScope::star() line 97
public function nested(
NestedInput $node,
Derivation $derivation,
Environment $outer,
bool $leading,
): JoinedInputDerives the terms inside parentheses and answers what the parentheses make visible.
Around one term the parentheses replace its correlation name with their own, unless they are plain parentheses at the very start of a FROM clause; around several terms the relations inside stay visible, and a correlation name on the parentheses names the joined row, reachable with that qualifier only.
Parameters
$node | NestedInput | |
$derivation | Derivation | |
$outer | Environment | |
$leading | bool |
Returns
Test cases 2
Called from 1
Calls 6
- method-call FromScope::open() line 111
- function-call
countline 112 - new VisibleRelation line 116
- function-call
in_arrayline 117 - class-const ColumnResolver::QUALIFIED_ONLY() line 117
- new JoinedInput line 125
public function star(list<VisibleRelation> $visible): RowShapeAnswers the row that * selects from visible relations: every column except the merged ones, without the relations reachable by qualifier only.
Parameters
$visible | list<VisibleRelation> |
Returns
Test cases 1
Called from 1
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
FromScopeTest::testEnterDerivesEveryOnConditionInTheScopeOfTheWholeChaincallsFromScopeTest::testEnterReportsConstraintsWithoutAJoinAndInvalidOperatorscallsFromScopeTest::testNestedAddsAQualifiedOnlyRelationForAnAliasedJoincallsFromScopeTest::testNestedRenamesASingleTermByTheAliasOrKeepsItsRelationscallsFromScopeTest::testOpenEntersAChainOrANestedInputAndRecordsItsFactcallsFromScopeTest::testOpenMakesATableVisibleWithItsNameAliasAndRowIdentifiercallsFromScopeTest::testOpenResolvesTableCallArgumentsAgainstTheTermsToTheLeftcallsFromScopeTest::testStarListsTheUnhiddenSlotsOfQualifiableRelationsOnlycalls
Relations§
Instantiated in 4
- new SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:47
- new SqlSemantics\Platform\Sqlite\Statement\Mutation\Update::deriveWithin() packages/sql-semantics-sqlite/src/Statement/Mutation/Update.php:107
- new SqlSemantics\Platform\Sqlite\Statement\Relation\JoinChain::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Relation/JoinChain.php:66
- new SqlSemantics\Platform\Sqlite\Statement\Relation\NestedInput::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Relation/NestedInput.php:53
Method calls 4
- method-call SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::derive() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:47
- method-call SqlSemantics\Platform\Sqlite\Statement\Mutation\Update::deriveWithin() packages/sql-semantics-sqlite/src/Statement/Mutation/Update.php:107
- method-call SqlSemantics\Platform\Sqlite\Statement\Relation\JoinChain::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Relation/JoinChain.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Relation\NestedInput::deriveRelation() packages/sql-semantics-sqlite/src/Statement/Relation/NestedInput.php:53