classWithClause
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.
$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> $tablespublic bool $recursive = falseMethods§
public function __construct(list<CommonTableExpression> $tables, public bool $recursive = false)Parameters
$tables | list<CommonTableExpression> | The common table expressions in written order; at least one |
$recursive | bool | Whether RECURSIVE is written |
Calls 2
- static-call Check::listOf() line 43
- class-const CommonTableExpression::class() line 43
public function deriveCommonTables(Derivation $derivation, Environment $outer): EnvironmentDerives the common table expressions and answers the environment in which they are visible.
Parameters
$derivation | Derivation | |
$outer | Environment |
Returns
Test cases 1
Calls 2
- method-call CommonTableFacts::bind() line 51
- new CommonTableFacts line 51
public function render(Output $out): voidWrites WITH, RECURSIVE and the common table expressions.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::keyword() line 59
- method-call Output::list() line 63
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
PlacementTest::testObjectsStopsAtNestedModificationscallsCommonTableFactsTest::testBindMakesTheTablesVisiblecallsCommonTableFactsTest::testMarkIsTheCommonTypeOfTheValuescallsCommonTableFactsTest::testMemberReportsASearchColumnTheTableLackscallsCommonTableFactsTest::testOrderDerivesReferencedTablesFirstcallsCommonTableFactsTest::testRecursiveFormReportsAQueryWithoutUnioncallsCommonTableFactsTest::testShapeAddsTheSearchAndCycleColumnscallsSetOperationFactsTest::testReboundBindsTheRecursiveTablecallsTableShapesTest::testInputReportsASampleOfACommonTablecallsDeleteTest::testCommonTablesAnswersTheWithClausecallsInsertDefaultsTest::testCommonTablesAnswersTheWithClausecallsInsertRowsTest::testCommonTablesAnswersTheWithClausecallsInsertSelectTest::testCommonTablesAnswersTheWithClausecallsMergeTest::testCommonTablesAnswersTheWithClausecallsUpdateTest::testCommonTablesAnswersTheWithClausecalls
Relations§
Instantiated in 2
Type checks 4
- instanceof SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::attach() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:171
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement::modifying() packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:97
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Roots::derive() packages/sql-semantics-postgres/src/Rules/Manipulation/Roots.php:34
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\ModifyingCommonTables::check() packages/sql-semantics-postgres/src/Rules/Query/Facts/ModifyingCommonTables.php:41
Type declarations 7
- type SqlSemantics\Platform\PostgreSql\Lowering\Query\WithRule packages/sql-semantics-postgres/src/Lowering/Query/WithRule.php:45
- type SqlSemantics\Platform\PostgreSql\Rules\Manipulation\Placement packages/sql-semantics-postgres/src/Rules/Manipulation/Placement.php:94
- type SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\CommonTableFacts packages/sql-semantics-postgres/src/Rules/Query/Facts/CommonTableFacts.php:64
- type SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\CommonTableFacts packages/sql-semantics-postgres/src/Rules/Query/Facts/CommonTableFacts.php:131
- type SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\ModifyingCommonTables packages/sql-semantics-postgres/src/Rules/Query/Facts/ModifyingCommonTables.php:38
- type SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\ModifyingCommonTables packages/sql-semantics-postgres/src/Rules/Query/Facts/ModifyingCommonTables.php:56
- type SqlSemantics\Platform\PostgreSql\Statement\Query\QueryExpression packages/sql-semantics-postgres/src/Statement/Query/QueryExpression.php:49