classWithQuery
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.
$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 $withpublic Select|ValuesClause|Compound $bodyMethods§
public function __construct(public WithClause $with, public Select|ValuesClause|Compound $body)Parameters
$with | WithClause | The WITH clause |
$body | Select|ValuesClause|Compound | The query the clause belongs to |
public function deriveStatement(Derivation $derivation): voidDerives the query as a statement root and records its rows as the output.
Parameters
$derivation | Derivation |
Calls 5
- method-call ProgramOnly::outsideProgram() line 50
- new ProgramOnly line 50
- method-call Derivation::output() line 51
- method-call Derivation::query() line 51
- method-call Derivation::environment() line 51
public function deriveQuery(Derivation $derivation, Environment $outer): QueryFactBinds the common tables and derives the body where they are visible.
Parameters
$derivation | Derivation | |
$outer | Environment |
Returns
Calls 4
- method-call Derivation::query() line 59
- method-call CommonTables::bind() line 59
- new CommonTables line 59
- new QueryFact line 61
public function render(Output $out): voidTest 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
NameRuleTest::testCollationLowersTheCollationNameOrNullWhenNoneIsWrittencallsMutationRuleTest::testInsertLowersWrittenRowsAndEveryOtherSourceAsAQuerycallsQueryCommandsTest::testCommandLowersEveryFormOfASelectCommandcallsSelectRuleTest::testSelectLowersAPlainQueryAndAQueryWithCommonTablescallsSortRuleTest::testColumnsLowersTheNamesOfAColumnListWithCollationAndDirectioncallsSortRuleTest::testOptionalColumnsGivesNoColumnsWithoutParenthesescallsWithRuleTest::testClauseKeepsTheCommonTablesInWrittenOrdercallsWithRuleTest::testClauseReadsTheRecursiveKeywordcallsWithRuleTest::testTableLowersTheNameTheColumnsTheQueryAndTheMaterializationHintcallsCommonTableTest::testDefinitionIsTheCommonTableNodeOfTheStatementcallsCommonTableTest::testDefinitionShadowsADeclaredTableOfTheSameNamecallsExpressionAffinityTest::testArmsFlattensWithClausesCompoundsAndValuesRowscallsExpressionAffinityTest::testComputingAnswersTheQueryOfADerivedTableOrACommonTablecallsCommonTablesTest::testBindMakesEveryTableVisibleWhateverTheWrittenOrdercallsCommonTablesTest::testBindReportsARepeatedNameAndACircularReferencecallsCommonTablesTest::testBindTypesARecursiveReferenceAsAnyStorageClasscallsCommonTablesTest::testProvisionalHasOneSlotPerListedColumnThatCanHoldAnythingcallsCommonTablesTest::testShapeDependsOnTheMissingInputsOfAnOpenQuerycallsCommonTablesTest::testShapeKeepsTheQueryNamesWithoutAListAndReportsADecoratedNamecallsCommonTablesTest::testShapeRenamesTheColumnsByTheListAndReportsAnotherLengthcallsCommonTablesTest::testUsesAnswersTheUnqualifiedTableNamesFoldedcallsCompoundFactsTest::testReboundGivesTheRecursiveReferenceTheNamesOfTheColumnListAndAnyStorageClasscallsCompoundFactsTest::testReboundNamesTheColumnsAfterTheFirstArmWithoutAColumnListcallsResultNamesTest::testLeftmostFindsTheArmThatNamesTheColumnscallsTableShapesTest::testFactCopiesTheShapeOfACommonTableAndLinksItsSlotscallsListedColumnTest::testRenderWritesANewlyBuiltNamecallsListedColumnTest::testRenderWritesTheNameTheCollationAndTheDirectioncallsCommonTableTest::testRenderWritesANewlyBuiltTablecallsCommonTableTest::testRenderWritesTheColumnListAndTheHintcallsWithClauseTest::testRenderWritesRecursiveAndEveryTablecallsTableInputTest::testDeriveRelationResolvesACommonTableToItsDefinitioncalls
Relations§
Instantiated in 2
Constant reads 1
Type checks 3
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity::arms() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:201
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::leftmost() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:209
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames::leftmost() packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:210