classCompoundFacts
final class CompoundFacts
Derives the facts of a compound query.
Rule: SQLITE-COMPOUND-SCOPE-001. Every arm is derived in the enclosing environment. The output has the names of the first arm; the type of a column is the choice over the arms and it can be NULL when it can in an arm. Arms of different widths are reported, as are ORDER BY and LIMIT on an arm that is not the last. When the compound is the query of a common table that refers to itself, the arms after the first see the table with the column names of its column list or of the first arm; because later rounds of the recursion feed their own results back, a column of the recursive reference can hold any storage class or NULL. An ORDER BY term is a result column position, or an expression over the result column names of the arms. Terminates: one pass over the arms; no fixpoint is computed. Source: https://sqlite.org/lang_select.html#compound_select_statements, https://sqlite.org/lang_with.html#recursive_common_table_expressions. Status: Implemented.
Methods§
public function derive(
Compound $compound,
Derivation $derivation,
Environment $outer,
): QueryFactDerives every part of the compound query and answers its output.
Parameters
$compound | Compound | |
$derivation | Derivation | |
$outer | Environment |
Returns
Test cases 2
Called from 1
Calls 18
- method-call Derivation::query() line 72
- method-call CompoundFacts::rebound() line 75
- function-call
countline 77 - method-call Derivation::report() line 78
- new Misuse line 78
- class-const MisuseRule::OrderByBeforeCompound() line 78
- class-const MisuseRule::LimitBeforeCompound() line 78
- new VisibleRelation line 81
- new RowShape line 81
- method-call CompoundFacts::combined() line 84
- function-call
array_mapline 85 - method-call SortScopes::derive() line 86
- new SortScopes line 86
- new Environment line 86
- method-call CompoundFacts::aliases() line 86
- method-call SelectFacts::limit() line 87
- new SelectFacts line 87
- new QueryFact line 89
public function combined(
non-empty-list<QueryFact> $facts,
Derivation $derivation,
): list<Field|OpenStar>Combines the outputs of the arms into the output of the compound query.
Parameters
$facts | non-empty-list<QueryFact> | The outputs of the arms in written order |
$derivation | Derivation |
Test cases 3
Called from 1
Calls 12
- new OpenStar line 102
- class-const Nullability::NotNull() line 108
- function-call
countline 111 - method-call Derivation::report() line 113
- new ArityMismatch line 113
- class-const ArityRule::CompoundArms() line 113
- new Dependent line 118
- class-const Nullability::Dependent() line 119
- new Field line 121
- new OutputSlot line 121
- method-call Storages::either() line 121
- new Storages line 121
public function aliases(
list<Query> $arms,
list<QueryFact> $facts,
list<Field|OpenStar> $items,
): list<Field>Answers the result column names of every arm as aliases of the output fields at the same positions.
A name SQLite takes from the text of an expression is no alias an ORDER BY term can name.
Parameters
Returns
list<Field>Test cases 1
Called from 1
Calls 3
- method-call CompoundFacts::spelled() line 144
- new Field line 145
- new OutputSlot line 145
Tells whether an arm names a field after the text of its expression.
Returns
boolTest cases 1
Called from 1
Calls 2
- method-call ResultNames::column() line 158
- new ResultNames line 158
public function rebound(
Compound $compound,
QueryFact $anchor,
Environment $outer,
Derivation $derivation,
): EnvironmentAnswers the environment of the arms after the first: the one given, with the common table this compound defines bound to its recursive shape.
Parameters
$compound | Compound | |
$anchor | QueryFact | |
$outer | Environment | |
$derivation | Derivation |
Returns
Test cases 3
Called from 1
Calls 11
- method-call RelationNames::listed() line 180
- new RelationNames line 180
- function-call
array_mapline 180 - method-call RelationNames::shape() line 181
- new OutputSlot line 183
- new Choice line 183
- static-call Storage::cases() line 183
- class-const Nullability::Nullable() line 183
- new CommonBinding line 185
- new RowShape line 185
- new Environment line 191
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
CompoundFactsTest::testAliasesNamesTheOutputAfterEveryArmcallsCompoundFactsTest::testCombinedAnswersAnOpenStarWhenTheFirstArmIsOpencallsCompoundFactsTest::testCombinedDependsOnAnOpenLaterArmcallsCompoundFactsTest::testCombinedTakesTheNamesOfTheFirstArmAndReportsAnotherWidthOncecallsCompoundFactsTest::testDeriveCombinesTheArmsAndOrdersByTheNamesOfEveryArmcallsCompoundFactsTest::testDeriveReportsAnOrderingOrALimitOnAnEarlierArmcallsCompoundFactsTest::testReboundGivesTheRecursiveReferenceTheNamesOfTheColumnListAndAnyStorageClasscallsCompoundFactsTest::testReboundLeavesAnEnvironmentWithoutTheTableUntouchedcallsCompoundFactsTest::testReboundNamesTheColumnsAfterTheFirstArmWithoutAColumnListcallsCompoundFactsTest::testSpelledTellsANameTakenFromTheTextOfAnExpressioncalls