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\PostgreSql\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 34§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Other tests reaching this symbol 34
ColumnFactsTest::testAliasReportsSeveralOutputColumnscallsColumnFactsTest::testDeriveRefersToAnOutputColumnByNamecallsSublinksTest::testArrayIsAnArrayOfTheColumnTypecallsSublinksTest::testValueIsARowForSeveralColumnscallsMergeFactsTest::testBySourceMakesTheSourceColumnsNullablecallsMergeFactsTest::testNullableKeepsTheTypescallsModificationScopeTest::testOpenBindsTheCommonTablescallsModificationScopeTest::testReturningSeesTheTargetAndTheOtherInputscallsRootsTest::testDeriveRecordsTheRowsOfReturningcallsCommonTableFactsTest::testShapeAddsTheSearchAndCycleColumnscallsSelectFactsTest::testGroupedMakesFieldsNullableWithGroupingSetscallsSelectFactsTest::testTableExpandsTheTablecallsValuesFactsTest::testDeriveResolvesEachColumncallsOrderingTest::testKnownStopsAtAnOpenStarcallsOrderingTest::testPositionsListsTheKnownFieldscallsOrderingTest::testSameComparesTheExpressionscallsStarExpansionTest::testAllSkipsTablesInsideAJoincallsStarExpansionTest::testQualifiedSelectsTheMergedColumnToocallsUnknownOutputsTest::testRawKeepsAnUntypedLiteralUnknowncallsJoiningTest::testJoinPutsMergedColumnsFirstcallsTableFunctionShapesTest::testJsonHasTheColumnsInOrdercallsArraySubqueryTest::testDeriveScalarIsAnArrayOfTheColumnTypecallsExistsTest::testDeriveScalarIsANonNullBooleancallsInSubqueryTest::testDeriveScalarComparesWithTheColumncallsQuantifiedSubqueryTest::testDeriveScalarComparesWithTheColumncallsScalarSubqueryTest::testDeriveScalarHasTheColumnTypeAndCanBeNullcallsUniquePredicateTest::testDeriveScalarReportsThePredicatecallsPreparedParametersTest::testDeriveRelationTypesTheParametersOfThePreparedStatementcallsStarTargetTest::testProjectExpandsTheFromItemscallsFunctionTableTest::testDeriveRelationAddsOrdinalitycallsFunctionTableTest::testDeriveRelationHasTheDefinedColumnscallsJoinTest::testDeriveRelationExtendsTheRightSideOfALeftJoincallsJsonTableTest::testDeriveRelationFlattensNestedColumnscallsXmlTableTest::testDeriveRelationHasTheColumnscalls
Relations§
Instantiated in 12
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SelectFacts::grouped() packages/sql-semantics-postgres/src/Rules/Query/Facts/SelectFacts.php:186
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SetOperationFacts::combined() packages/sql-semantics-postgres/src/Rules/Query/Facts/SetOperationFacts.php:84
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\ValuesFacts::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/ValuesFacts.php:61
- new SqlSemantics\Platform\PostgreSql\Rules\Query\StarExpansion::expand() packages/sql-semantics-postgres/src/Rules/Query/StarExpansion.php:124
- new SqlSemantics\Platform\PostgreSql\Rules\Utility\ExplainFacts::rows() packages/sql-semantics-postgres/src/Rules/Utility/ExplainFacts.php:75
- new SqlSemantics\Platform\PostgreSql\Statement\Query\ExpressionTarget::project() packages/sql-semantics-postgres/src/Statement/Query/ExpressionTarget.php:78
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Session\Show::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Session/Show.php:62
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Session\Show::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Session/Show.php:63
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Session\Show::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Session/Show.php:64
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Session\Show::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Session/Show.php:66
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Session\Show::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Session/Show.php:67
- new SqlSemantics\Platform\PostgreSql\Statement\Utility\Session\Show::deriveStatement() packages/sql-semantics-postgres/src/Statement/Utility/Session/Show.php:68
Constant reads 3
- class-const SqlSemantics\Platform\PostgreSql\Model\Statement\Shape\AmbiguousFields::__construct() packages/sql-semantics-postgres/src/Model/Statement/Shape/AmbiguousFields.php:33
- class-const SqlSemantics\Platform\PostgreSql\Model\Statement\Shape\DependentField::__construct() packages/sql-semantics-postgres/src/Model/Statement/Shape/DependentField.php:43
- class-const SqlSemantics\Platform\PostgreSql\Model\Statement\Shape\Fields::__construct() packages/sql-semantics-postgres/src/Model/Statement/Shape/Fields.php:43
Type checks 13
- instanceof SqlSemantics\Platform\PostgreSql\Model\Statement\Fact\QueryFact::__construct() packages/sql-semantics-postgres/src/Model/Statement/Fact/QueryFact.php:56
- instanceof SqlSemantics\Platform\PostgreSql\Model\Statement\Fact\QueryFact::lookup() packages/sql-semantics-postgres/src/Model/Statement/Fact/QueryFact.php:97
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\Sublinks::slots() packages/sql-semantics-postgres/src/Rules/Expression/Typing/Sublinks.php:143
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\DistinctOrdering::key() packages/sql-semantics-postgres/src/Rules/Query/DistinctOrdering.php:85
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\QueryRoots::table() packages/sql-semantics-postgres/src/Rules/Query/Facts/QueryRoots.php:90
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\QueryRoots::table() packages/sql-semantics-postgres/src/Rules/Query/Facts/QueryRoots.php:91
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SelectFacts::grouped() packages/sql-semantics-postgres/src/Rules/Query/Facts/SelectFacts.php:185
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::known() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:158
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering::named() packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:177
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\ColumnAliases::fromQuery() packages/sql-semantics-postgres/src/Rules/Resolution/ColumnAliases.php:65
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\QueryTables::table() packages/sql-semantics-postgres/src/Rules/Table/Definition/QueryTables.php:76
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\QueryTables::table() packages/sql-semantics-postgres/src/Rules/Table/Definition/QueryTables.php:77
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\QueryTables::table() packages/sql-semantics-postgres/src/Rules/Table/Definition/QueryTables.php:78
Type declarations 6
- type SqlSemantics\Platform\PostgreSql\Model\Statement\Operation packages/sql-semantics-postgres/src/Model/Statement/Operation.php:120
- type SqlSemantics\Platform\PostgreSql\Model\Statement\Reference\Column\AliasTarget packages/sql-semantics-postgres/src/Model/Statement/Reference/Column/AliasTarget.php:27
- type SqlSemantics\Platform\PostgreSql\Model\Statement\Shape\Fields packages/sql-semantics-postgres/src/Model/Statement/Shape/Fields.php:70
- type SqlSemantics\Platform\PostgreSql\Model\Statement\Shape\UniqueField packages/sql-semantics-postgres/src/Model/Statement/Shape/UniqueField.php:24
- type SqlSemantics\Platform\PostgreSql\Rules\Query\Ordering packages/sql-semantics-postgres/src/Rules/Query/Ordering.php:195
- type SqlSemantics\Platform\PostgreSql\Rules\Query\UnknownOutputs packages/sql-semantics-postgres/src/Rules/Query/UnknownOutputs.php:33