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.

Reading a derived querydoctest
$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 $query
public Name|null $alias = null
public bool $as = true

Methods§

public function __construct(
    public Query $query,
    public Name|null $alias = null,
    public bool $as = true,
)

Parameters

$queryQueryThe query
$aliasName|nullThe correlation name
$asboolWhether the keyword AS introduces the alias; SQLite names a column after the text of an expression, which includes it

Throws

InvalidConstruction When AS is left out without an alias
Calls 1
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Derives the query and the row shape its result gives the occurrence.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 4
public function render(Output $out): void

Writes the query in parentheses and the correlation name.

Parameters

$outOutput
Calls 4

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

Relations§

Instantiated in 1
Type checks 2