final class CycleClause
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

CYCLE columns SET mark [TO value DEFAULT value] USING path: cycle detection added to a recursive query.

Mirrors PostgreSQL's CTECycleClause. The mark column and the path column are appended to the columns of the common table. Without the TO and DEFAULT values the mark is a boolean that is true on a cycle. The WITH clause derives the values, which see no column. Source: https://www.postgresql.org/docs/17/queries-with.html#QUERIES-WITH-CYCLE.

Reading a cycle clausedoctest
$clause = new \SqlSemantics\Platform\PostgreSql\Statement\Query\With\CycleClause([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('id')], new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('is_cycle'), new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('path'));
    [$clause->mark->value, $clause->path->value, $clause->markValue] // => ['is_cycle', 'path', null]
Refusing a mark value without its defaultdoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Query\With\CycleClause([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('id')], new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('m'), new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('p'), new \SqlSemantics\Platform\PostgreSql\Statement\Literal\BooleanLiteral(true)) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public non-empty-list<Name> $columns
public Name $mark
public Name $path
public Scalar|null $markValue = null
public Scalar|null $markDefault = null

Methods§

public function __construct(
    list<Name> $columns,
    public Name $mark,
    public Name $path,
    public Scalar|null $markValue = null,
    public Scalar|null $markDefault = null,
)

Parameters

$columnslist<Name>The columns compared to detect a cycle; at least one
$markNameThe name of the added mark column
$pathNameThe name of the added path column
$markValueScalar|nullThe mark of a row on a cycle, written after TO
$markDefaultScalar|nullThe mark of every other row, written after DEFAULT
Calls 3
public function render(Output $out): void

Writes the clause.

Parameters

$outOutput
Test cases 1
Calls 4

Test cases 3§

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

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Instantiated in 2
Type declarations 2