final class WithQuery
    implements Statement, Query
    uses Snapshot
Public API: explicitly declared with @visibility public.

A query with its own WITH clause.

Rule: SQLITE-WITH-QUERY-001. The common tables are bound by SQLITE-COMMON-TABLE-001 and are visible in the body and in every query nested in it. The output is that of the body. Source: https://sqlite.org/lang_with.html. Status: Implemented.

Reading the body of a query with common tablesdoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('WITH c AS (SELECT 1 AS x) SELECT x FROM c');
    [$query->statement->body->columns[0]->expression->name->value, $query->field('x')->type->descriptor] // => ['x', \SqlSemantics\Platform\Sqlite\Statement\Type\Storage::Integer]

Properties§

public WithClause $with

Methods§

public function __construct(public WithClause $with, public Select|ValuesClause|Compound $body)

Parameters

$withWithClauseThe WITH clause
$bodySelect|ValuesClause|CompoundThe query the clause belongs to
public function deriveStatement(Derivation $derivation): void

Derives the query as a statement root and records its rows as the output.

Parameters

$derivationDerivation
Calls 5
public function deriveQuery(Derivation $derivation, Environment $outer): QueryFact

Binds the common tables and derives the body where they are visible.

Parameters

$derivationDerivation
$outerEnvironment

Returns

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

Writes the clause and the body.

Parameters

$outOutput
Calls 1

Test cases 35§

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 31

Relations§

Instantiated in 2
Constant reads 1
Type checks 3
Type declarations 2