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\MySql\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
Called from 1
Calls 1
- method-call OutputSlot::declaration() line 69
Test cases 27§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Other tests reaching this symbol 27
SubqueryRowsTest::testTestCombinesTheColumnsAndReportsAWidthMismatchcallsSubqueryRowsTest::testValueIsTheOneColumnOrARowcallsCommonTablesTest::testAnchoredBindsTheColumnsOfTheNonrecursivePartcallsCommonTablesTest::testNullableMakesEveryColumnNullablecallsCommonTablesTest::testShapeRenamesTheColumnsByTheColumnListcallsDerivedShapesTest::testShapeTakesTheSlotsOfTheQuerycallsJoiningTest::testJoinMergesTheUsingColumnscallsProjectionTest::testItemsDerivesExpressionsAndStarscallsResultSlotsTest::testCombineNamesAfterTheLeftOperandcallsResultSlotsTest::testValuesNamesTheColumnsByPositioncallsSelectFactsTest::testAliasesAnswersTheFieldsNamedByAnAliasOrAfterTheirTextcallsTableShapesTest::testImplicitFindsInvisibleColumnsByNameOnlycallsTableShapesTest::testNamedPrefersACommonTablecallsViewColumnsTest::testNamesRenamesGeneratedNamesThatAreNotValidOrRepeatedcallsViewColumnsTest::testNamesUsesTheLegacyPrefixIn57callsExplicitTableTest::testDeriveQueryAnswersEveryColumnOfTheTablecallsSelectExpressionTest::testDeriveNamesSelfNamedItemsByTheirOwnNamescallsSelectExpressionTest::testDeriveNamesTheColumnsOfACommonTableAndOfAUnionAfterTheFirstOperandcallsSelectExpressionTest::testDeriveNamesTheColumnsOfACreatedTablecallsSelectExpressionTest::testRenderKeepsTheTextTheServerNamesAnUnaliasedItemAftercallsSelectTest::testDeriveQueryExpandsStarsOverJoinscallsSelectTest::testDeriveQueryNamesTheFieldsAfterAliasesAndColumnscallsSetOperationTest::testDeriveQueryNamesTheColumnsAfterTheFirstOperandAndCombinesNullabilitycallsValuesQueryTest::testDeriveQueryNamesTheColumnsAndCombinesTheRowscallsJoinedTableTest::testDeriveRelationMergesTheCommonColumnsOfANaturalJoincallsJsonTableTest::testDeriveRelationAnswersTheColumnsOfTheDefinitionscallsTableListTest::testDeriveRelationJoinsTheMembersLeftToRightcalls
Relations§
Instantiated in 14
- new SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::open() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:135
- new SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::open() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:150
- new SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::column() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:168
- new SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::column() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:172
- new SqlSemantics\Platform\MySql\Rules\Dml\WriteScope::field() packages/sql-semantics-mysql/src/Rules/Dml/WriteScope.php:45
- new SqlSemantics\Platform\MySql\Rules\Query\CommonTables::nullable() packages/sql-semantics-mysql/src/Rules/Query/CommonTables.php:141
- new SqlSemantics\Platform\MySql\Rules\Query\Having\HavingScope::grouping() packages/sql-semantics-mysql/src/Rules/Query/Having/HavingScope.php:79
- new SqlSemantics\Platform\MySql\Rules\Query\Projection::items() packages/sql-semantics-mysql/src/Rules/Query/Projection.php:61
- new SqlSemantics\Platform\MySql\Rules\Query\Projection::field() packages/sql-semantics-mysql/src/Rules/Query/Projection.php:149
- new SqlSemantics\Platform\MySql\Rules\Query\ResultSlots::combine() packages/sql-semantics-mysql/src/Rules/Query/ResultSlots.php:73
- new SqlSemantics\Platform\MySql\Rules\Query\ResultSlots::values() packages/sql-semantics-mysql/src/Rules/Query/ResultSlots.php:119
- new SqlSemantics\Platform\MySql\Rules\Query\TableShapes::explicit() packages/sql-semantics-mysql/src/Rules/Query/TableShapes.php:97
- new SqlSemantics\Platform\MySql\Rules\Server\AdminRows::record() packages/sql-semantics-mysql/src/Rules/Server/AdminRows.php:77
- new SqlSemantics\Platform\MySql\Rules\Utility\ShowFacts::query() packages/sql-semantics-mysql/src/Rules/Utility/ShowFacts.php:109
Method calls 1
Constant reads 4
- class-const SqlSemantics\Platform\MySql\Model\Statement\Shape\AmbiguousFields::__construct() packages/sql-semantics-mysql/src/Model/Statement/Shape/AmbiguousFields.php:33
- class-const SqlSemantics\Platform\MySql\Model\Statement\Shape\DependentField::__construct() packages/sql-semantics-mysql/src/Model/Statement/Shape/DependentField.php:43
- class-const SqlSemantics\Platform\MySql\Model\Statement\Shape\Fields::__construct() packages/sql-semantics-mysql/src/Model/Statement/Shape/Fields.php:43
- class-const SqlSemantics\Platform\MySql\Statement\Name\AmbiguousAlias::__construct() packages/sql-semantics-mysql/src/Statement/Name/AmbiguousAlias.php:43
Type checks 10
- instanceof SqlSemantics\Platform\MySql\Model\Statement\Fact\QueryFact::__construct() packages/sql-semantics-mysql/src/Model/Statement/Fact/QueryFact.php:56
- instanceof SqlSemantics\Platform\MySql\Model\Statement\Fact\QueryFact::lookup() packages/sql-semantics-mysql/src/Model/Statement/Fact/QueryFact.php:97
- instanceof SqlSemantics\Platform\MySql\Rules\Query\CommonTables::nullable() packages/sql-semantics-mysql/src/Rules/Query/CommonTables.php:141
- instanceof SqlSemantics\Platform\MySql\Rules\Query\ExpressionFacts::ordering() packages/sql-semantics-mysql/src/Rules/Query/ExpressionFacts.php:52
- instanceof SqlSemantics\Platform\MySql\Rules\Query\Having\HavingScope::undecided() packages/sql-semantics-mysql/src/Rules/Query/Having/HavingScope.php:105
- instanceof SqlSemantics\Platform\MySql\Rules\Query\Having\ResultReferences::selected() packages/sql-semantics-mysql/src/Rules/Query/Having/ResultReferences.php:94
- instanceof SqlSemantics\Platform\MySql\Rules\Query\Having\ResultReferences::unnamed() packages/sql-semantics-mysql/src/Rules/Query/Having/ResultReferences.php:140
- instanceof SqlSemantics\Platform\MySql\Rules\Query\SelectFacts::aliases() packages/sql-semantics-mysql/src/Rules/Query/SelectFacts.php:133
- instanceof SqlSemantics\Platform\MySql\Rules\Query\SortScopes::derive() packages/sql-semantics-mysql/src/Rules/Query/SortScopes.php:68
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration::settled() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:220
Type declarations 10
- type SqlSemantics\Platform\MySql\Model\Statement\Operation packages/sql-semantics-mysql/src/Model/Statement/Operation.php:120
- type SqlSemantics\Platform\MySql\Model\Statement\Reference\Column\AliasTarget packages/sql-semantics-mysql/src/Model/Statement/Reference/Column/AliasTarget.php:27
- type SqlSemantics\Platform\MySql\Model\Statement\Shape\Fields packages/sql-semantics-mysql/src/Model/Statement/Shape/Fields.php:70
- type SqlSemantics\Platform\MySql\Model\Statement\Shape\UniqueField packages/sql-semantics-mysql/src/Model/Statement/Shape/UniqueField.php:24
- type SqlSemantics\Platform\MySql\Rules\Dml\GeneratedWrites packages/sql-semantics-mysql/src/Rules/Dml/GeneratedWrites.php:66
- type SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:162
- type SqlSemantics\Platform\MySql\Rules\Dml\WriteScope packages/sql-semantics-mysql/src/Rules/Dml/WriteScope.php:41
- type SqlSemantics\Platform\MySql\Rules\Dml\WriteScope packages/sql-semantics-mysql/src/Rules/Dml/WriteScope.php:51
- type SqlSemantics\Platform\MySql\Rules\Query\Projection packages/sql-semantics-mysql/src/Rules/Query/Projection.php:147
- type SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:232