final class WithClause
    implements CommonTables
    uses Snapshot
Public API: explicitly declared with @visibility public.

WITH [RECURSIVE] and its common table expressions.

Mirrors PostgreSQL's WithClause. The facts are derived by PG-COMMON-TABLE-001. Source: https://www.postgresql.org/docs/17/queries-with.html.

Reading a recursive WITH clausedoctest
$one = new \SqlSemantics\Platform\PostgreSql\Statement\Query\Select([new \SqlSemantics\Platform\PostgreSql\Statement\Query\ExpressionTarget(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant('1')))]);
    $with = new \SqlSemantics\Platform\PostgreSql\Statement\Query\With\WithClause([new \SqlSemantics\Platform\PostgreSql\Statement\Query\With\CommonTableExpression(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('x'), $one)], true);
    [$with->recursive, count($with->tables)] // => [true, 1]

Properties§

public non-empty-list<CommonTableExpression> $tables
public bool $recursive = false

Methods§

public function __construct(list<CommonTableExpression> $tables, public bool $recursive = false)

Parameters

$tableslist<CommonTableExpression>The common table expressions in written order; at least one
$recursiveboolWhether RECURSIVE is written
Calls 2
public function deriveCommonTables(Derivation $derivation, Environment $outer): Environment

Derives the common table expressions and answers the environment in which they are visible.

Parameters

$derivationDerivation
$outerEnvironment
Test cases 1
Calls 2
public function render(Output $out): void

Writes WITH, RECURSIVE and the common table expressions.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 17§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 2
Other tests reaching this symbol 15

Relations§

Instantiated in 2
Type checks 4
Type declarations 7