classDerivedQuery
final class DerivedQuery
implements Relation
uses Snapshot
Public API: explicitly declared with
@visibility public.A query in parentheses used as query input.
Rule: SQLITE-DERIVED-QUERY-001. The query is derived in the environment that encloses the FROM clause: it sees the enclosing queries and no sibling of its own FROM clause. Its columns are the result columns of the query, named by SQLITE-RELATION-NAME-001. Source: https://sqlite.org/lang_select.html#the_from_clause. Status: Implemented.
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT x FROM (SELECT 1 AS x) AS d');
[$query->statement->from->alias->value, $query->field('x')->type->descriptor] // => ['d', \SqlSemantics\Platform\Sqlite\Statement\Type\Storage::Integer]Properties§
public Query $querypublic Name|null $alias = nullpublic bool $as = trueMethods§
public function __construct(
public Query $query,
public Name|null $alias = null,
public bool $as = true,
)Parameters
Throws
InvalidConstruction When AS is left out without an aliasCalls 1
- static-call Check::input() line 45
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives the query and the row shape its result gives the occurrence.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new RelationFact line 53
- method-call RelationNames::shape() line 53
- new RelationNames line 53
- method-call Derivation::query() line 53
public function render(Output $out): voidWrites the query in parentheses and the correlation name.
Parameters
$out | Output |
Calls 4
- method-call Output::symbol() line 61
- method-call Output::keyword() line 64
- method-call Output::name() line 66
- class-const NameUse::Alias() line 66
Test cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 5
FromRuleTest::testTermLowersEachKindOfTermWithItsAliascallsFactsTest::testQueryAnswersTheFactOfAQueryOfTheOperationcallsRelationFactTest::testTableIsNullForAnOccurrenceWithoutANamecallsExpressionAffinityTest::testComputingAnswersTheQueryOfADerivedTableOrACommonTablecallsExpressionAffinityTest::testPositionFindsTheOutputFieldASlotReExposescalls
Relations§
Instantiated in 1
Type checks 2
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity::computing() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:163
- instanceof SqlSemantics\Platform\Sqlite\Rules\Resolution\FromScope::open() packages/sql-semantics-sqlite/src/Rules/Resolution/FromScope.php:61