classField
final class Field
uses Snapshot
Public API: explicitly declared with
@visibility public.One output field of a query, with the facts the operation derived for it.
A field belongs to the operation that derived it. It is a reading result, not an input for building another query.
$semantics = new \SqlSemantics\Platform\Sqlite\Semantics();
$table = $semantics->analyze('CREATE TABLE t (a INTEGER)');
$field = $semantics->analyze('SELECT a AS x FROM t', [$table])->field('x');
[$field->position, $field->name?->value, $field->column()?->name->value] // => [0, 'x', 'a']Properties§
public Name|null $namepublic TypeFact $typepublic Nullability $nullabilitypublic int $positionpublic OutputSlot $slotpublic Scalar|null $expression = nullpublic Resolution|null $resolution = nullMethods§
public function __construct(
public int $position,
public OutputSlot $slot,
public Scalar|null $expression = null,
public Resolution|null $resolution = null,
)Parameters
$position | int | The zero-based output position |
$slot | OutputSlot | The output position with its name and facts |
$expression | Scalar|null | The expression that computes the field; null when no single expression does, as for a set operation |
$resolution | Resolution|null | The name resolution when the expression is a direct name use |
public function column(): ?ColumnAnswers the declared column the field directly returns, when it is one.
Returns
Calls 1
- method-call OutputSlot::declaration() line 69
Test cases 61§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
FieldTestcalls
Other tests reaching this symbol 60
ResultRuleTest::testAliasReadsTheAliasAfterAsABareWordAStringOrNonecallsResultRuleTest::testValuesLowersEveryRowInWrittenOrdercallsEnvironmentTest::testAliasedFindsEveryOutputFieldWithTheAliascallsQueryFactTest::testFieldsIsNullWhileAStarCannotBeExpandedcallsQueryFactTest::testFieldsListsACompleteProjectionInOrdercallsQueryFactTest::testLookupDistinguishesUniqueAndAbsentInACompleteShapecallsQueryFactTest::testLookupIsDependentInAnOpenShapeEvenWhenACandidateIsKnowncallsQueryFactTest::testLookupIsNotReachedForAProjectionThatIsNoListcallsAmbiguousFieldsTest::testFieldsAreAtLeastTwocallsAmbiguousFieldsTest::testFieldsAreEveryFieldWithTheNameInOutputOrdercallsFieldsTest::testAtAnswersTheFieldAtAPositioncallsFieldsTest::testAtRefusesAPositionOutsideTheListcallsFieldsTest::testCountIsTheNumberOfOutputPositionscallsFieldsTest::testGetIteratorWalksTheFieldsInOutputOrdercallsFieldsTest::testLookupIsDependentWhileAFieldNameDependsOnMissingInputscallsFieldsTest::testLookupIsNotReachedWhenAFieldHoldsAnotherPositioncallsFieldsTest::testLookupIsSensitiveWhenTheProfileSaysSocallsFieldsTest::testLookupTellsOneNoneAndSeveralApartcallsOpenStarTest::testMissingNamesTheUndeclaredRelationBehindAStarcallsKnownTest::testDescriptorIsTheTypeTheRulesDeterminecallsPrecedenceTest::testClosingIsTheWeakestLevelOnTheRightEdgeAndClosedAfterAPostfixOperatorcallsPrecedenceTest::testOpeningIsTheWeakestLevelOnTheLeftEdgeAndClosedBeforeAPrefixOperatorcallsPrecedenceTest::testTakesEscapeFindsAPatternMatchWithoutEscapeOnTheRightEdgecallsCompoundFactsTest::testAliasesNamesTheOutputAfterEveryArmcallsCompoundFactsTest::testCombinedDependsOnAnOpenLaterArmcallsCompoundFactsTest::testCombinedTakesTheNamesOfTheFirstArmAndReportsAnotherWidthOncecallsCompoundFactsTest::testDeriveCombinesTheArmsAndOrdersByTheNamesOfEveryArmcallsProjectionTest::testExpandAppendsAnOpenStarForAnIncompleteRelationcallsProjectionTest::testExpandSkipsTheHiddenColumnsOnlyWhenMergedcallsProjectionTest::testItemsNamesEveryKindOfResultColumncallsProjectionTest::testItemsReportsAStarWithoutInputAndAQualifierThatNamesNoRelationcallsRelationNamesTest::testShapeNamesTheColumnsAfterTheLeftmostArmcallsSelectFactsTest::testAliasesAnswersTheFieldsWithAnExplicitAliasInOutputOrdercallsSelectFactsTest::testDeriveAnswersTheOutputAndRecordsEveryClausecallsColumnResolverTest::testFindPrefersARelationColumnOverAnAliasAndAnAliasOverOuterScopescallsBinaryTest::testDeriveScalarIsFamilyIsNeverNullcallsNullTestFormTest::testEachFormIsReadFromItsSpellingcallsNullTestTest::testDeriveScalarIsAnIntegerThatIsNeverNullcallsPatternOperatorTest::testEachOperatorIsReadFromItsSpellingcallsUnaryOperatorTest::testEachOperatorIsReadFromItsSpellingcallsInListTest::testDeriveScalarCanBeNullWhenTheOperandOrAValueCancallsInQueryTest::testDeriveScalarCanBeNullWhenTheOperandOrAComparedColumnCancallsDeleteTest::testDeriveStatementMakesReturningTheOutputOfTheTargetRowcallsInsertDefaultsTest::testDeriveStatementReturnsTheRowOfTheTargetcallsInsertRowsTest::testDeriveWithinLetsDoUpdateSeeTheTableAndExcludedcallsInsertSelectTest::testDeriveWithinBindsTheWithClauseForTheQueryAndReturnsTheTargetRowcallsUpdateTest::testDeriveWithinLetsReturningSeeTheTargetOnlycallsRandomColumnNameTest::testDescribeIsTheMissingInputOfALookupThatOnlyARandomlyNamedColumnCouldAnswercallsResultColumnTest::testRenderKeepsTheCommentAfterTheExpressioncallsResultColumnTest::testRenderKeepsTheNamesAndTheResultsSqliteGivescallsResultColumnTest::testRenderWritesANewlyBuiltColumncallsDerivedQueryTest::testDeriveRelationKeepsDuplicateNamesApartLikeSqlitecallsDerivedQueryTest::testDeriveRelationNamesTheRelationByItsResultColumnscallsJoinChainTest::testDeriveRelationCoalescesTheMergedColumnOfARightOrFullJoincallsJoinChainTest::testDeriveRelationListsCommaSeparatedTablesSideBySidecallsJoinChainTest::testDeriveRelationMakesTheExtendedSideNullablecallsJoinChainTest::testDeriveRelationShowsAMergedColumnOncecallsNestedInputTest::testDeriveRelationExposesTheJoinWrittenInParenthesescallsSignedNumberTest::testRenderWritesEveryKindOfNumericLiteralcallsStorageTest::testNameDescribesTheTypeOfALiteralcalls
Relations§
Instantiated in 6
- new SqlSemantics\Platform\Sqlite\Rules\Definition\ExplainRows::fact() packages/sql-semantics-sqlite/src/Rules/Definition/ExplainRows.php:70
- new SqlSemantics\Platform\Sqlite\Rules\Query\CompoundFacts::combined() packages/sql-semantics-sqlite/src/Rules/Query/CompoundFacts.php:121
- new SqlSemantics\Platform\Sqlite\Rules\Query\CompoundFacts::aliases() packages/sql-semantics-sqlite/src/Rules/Query/CompoundFacts.php:145
- new SqlSemantics\Platform\Sqlite\Rules\Query\Projection::items() packages/sql-semantics-sqlite/src/Rules/Query/Projection.php:66
- new SqlSemantics\Platform\Sqlite\Rules\Query\Projection::expand() packages/sql-semantics-sqlite/src/Rules/Query/Projection.php:96
- new SqlSemantics\Platform\Sqlite\Statement\Query\ValuesClause::deriveQuery() packages/sql-semantics-sqlite/src/Statement/Query/ValuesClause.php:90
Constant reads 3
- class-const SqlSemantics\Platform\Sqlite\Model\Statement\Shape\AmbiguousFields::__construct() packages/sql-semantics-sqlite/src/Model/Statement/Shape/AmbiguousFields.php:33
- class-const SqlSemantics\Platform\Sqlite\Model\Statement\Shape\DependentField::__construct() packages/sql-semantics-sqlite/src/Model/Statement/Shape/DependentField.php:43
- class-const SqlSemantics\Platform\Sqlite\Model\Statement\Shape\Fields::__construct() packages/sql-semantics-sqlite/src/Model/Statement/Shape/Fields.php:43
Type checks 12
- instanceof SqlSemantics\Platform\Sqlite\Model\Statement\Fact\QueryFact::__construct() packages/sql-semantics-sqlite/src/Model/Statement/Fact/QueryFact.php:56
- instanceof SqlSemantics\Platform\Sqlite\Model\Statement\Fact\QueryFact::lookup() packages/sql-semantics-sqlite/src/Model/Statement/Fact/QueryFact.php:97
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ColumnTyping::arm() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ColumnTyping.php:149
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity::position() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:184
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity::arm() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:231
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity::written() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:244
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\QueryColumns::settled() packages/sql-semantics-sqlite/src/Rules/Definition/Query/QueryColumns.php:73
- instanceof SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ValueKinds::arm() packages/sql-semantics-sqlite/src/Rules/Definition/Query/ValueKinds.php:156
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\CompoundFacts::aliases() packages/sql-semantics-sqlite/src/Rules/Query/CompoundFacts.php:144
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\RelationNames::shape() packages/sql-semantics-sqlite/src/Rules/Query/RelationNames.php:65
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\SelectFacts::aliases() packages/sql-semantics-sqlite/src/Rules/Query/SelectFacts.php:90
- instanceof SqlSemantics\Platform\Sqlite\Rules\Query\SortScopes::derive() packages/sql-semantics-sqlite/src/Rules/Query/SortScopes.php:50
Type declarations 9
- type SqlSemantics\Platform\Sqlite\Model\Statement\Operation packages/sql-semantics-sqlite/src/Model/Statement/Operation.php:120
- type SqlSemantics\Platform\Sqlite\Model\Statement\Reference\Column\AliasTarget packages/sql-semantics-sqlite/src/Model/Statement/Reference/Column/AliasTarget.php:27
- type SqlSemantics\Platform\Sqlite\Model\Statement\Shape\Fields packages/sql-semantics-sqlite/src/Model/Statement/Shape/Fields.php:70
- type SqlSemantics\Platform\Sqlite\Model\Statement\Shape\UniqueField packages/sql-semantics-sqlite/src/Model/Statement/Shape/UniqueField.php:24
- type SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ColumnTyping packages/sql-semantics-sqlite/src/Rules/Definition/Query/ColumnTyping.php:163
- type SqlSemantics\Platform\Sqlite\Rules\Definition\Query\ExpressionAffinity packages/sql-semantics-sqlite/src/Rules/Definition/Query/ExpressionAffinity.php:117
- type SqlSemantics\Platform\Sqlite\Rules\Query\CompoundFacts packages/sql-semantics-sqlite/src/Rules/Query/CompoundFacts.php:156
- type SqlSemantics\Platform\Sqlite\Rules\Query\RelationNames packages/sql-semantics-sqlite/src/Rules/Query/RelationNames.php:94
- type SqlSemantics\Platform\Sqlite\Rules\Query\ResultNames packages/sql-semantics-sqlite/src/Rules/Query/ResultNames.php:219