classColumnUse
final class ColumnUse
implements Scalar
uses Snapshot
@visibility public.A name used as a value: a request to resolve it as a column at its position.
The node holds the decoded column name and its optional table and database qualifiers. Which occurrence and declaration it denotes is a fact of the operation that contains it.
Rule: MYSQL-COLUMN-USE-001. Facts: the resolution of MYSQL-COLUMN-LOOKUP-001 over the relation occurrences of the position and, after them, the select list aliases the position may use; a use resolved to a slot or to an aliased item has the type and NULL fact of that slot or item; a conditional use depends on its missing inputs; a missing or ambiguous use is invalid and is a diagnostic. Terminates: the lookup is finite. Source: https://dev.mysql.com/doc/refman/8.4/en/identifier-qualifiers.html, https://dev.mysql.com/doc/refman/8.4/en/problems-with-alias.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT shop.t.a FROM shop.t');
$use = $query->statement->items[0]->expression;
[$use->qualifier?->schema?->value, $use->qualifier?->name->value, $use->name->value] // => ['shop', 't', 'a']Properties§
public Name $namepublic QualifiedName|null $qualifier = nullpublic OptionalWords $dot = OptionalWords::OmittedMethods§
public function __construct(
public Name $name,
public QualifiedName|null $qualifier = null,
public OptionalWords $dot = OptionalWords::Omitted,
)Parameters
$name | Name | The column name |
$qualifier | QualifiedName|null | The table the use is qualified with, and the database of that table when written |
$dot | OptionalWords | Whether the table qualifier is written after a leading dot, `.t.a` (MySQL 5.6 and 5.7) |
Calls 2
- class-const OptionalWords::Omitted() line 53
- static-call Check::input() line 55
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactResolves the name in the environment and derives its facts from the slot found.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call ColumnResolver::fact() line 64
- new ColumnResolver line 64
public function render(Output $out): voidWrites the qualifier parts and the name.
Parameters
$out | Output |
Calls 6
- class-const OptionalWords::Written() line 72
- method-call LeadingDot::write() line 73
- new LeadingDot line 73
- method-call Output::name() line 76
- class-const NameUse::Qualifier() line 76
- class-const NameUse::Column() line 81
Test cases 61§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 59
PrimaryRuleTest::testLeafLowersAColumnAndAParametercallsNameRuleTest::testColumnLowersEveryQualificationcallsNameRuleTest::testIdentifierDecodesEverySpellingOfANamecallsBlockTest::testFinishKeepsALaterOrderingAfterTheLockingClausesAsTheBlocksOwncallsBlockTest::testFinishOrdersTheRowsOfABlockThatLimitsItsRowscallsTrailerTest::testThenRejectsAClauseWrittenTwicecallsDiagnosticsRuleTest::testItemsLowersLocalVariableTargetscallsSignalRuleTest::testOperandLowersLiteralsVariablesAndNamescallsFlowRuleTest::testChoiceLowersASearchedCasecallsFlowRuleTest::testChoiceLowersASimpleCasecallsFlowRuleTest::testConditionalLowersAnIfWithoutElsecallsFlowRuleTest::testConditionalLowersTheBranchesAndTheElsecallsFlowRuleTest::testJumpLowersReturnLeaveAndIteratecallsFlowRuleTest::testLoopLowersLoopWhileAndRepeatcallsItemNamingTest::testNameAnswersTheAliasTheColumnNameOrTheTextcallsItemNamingTest::testNameRefusesALayoutOfAnItemThatNamesItselfcallsSortScopesTest::testWordAnswersABareUnqualifiedNamecallsBlockFactsTest::testVariablesHidesAParameterOfTheSameNamecallsPartitionFactsTest::testPartitioningDerivesTheClauseInTheScopecallsGroupConcatTest::testRenderWritesTheOrderingAndTheSeparatorcallsJsonObjectAggregateTest::testRenderWritesEachAllcallsCallArgumentTest::testRenderWritesTheAliascallsExtractTest::testRenderWritesTheUnitcallsJsonValueCallTest::testRenderWritesTheResponsescallsPositionTest::testRenderWritesIncallsDateArithmeticTest::testRenderWritesDateSubcallsTimestampCallTest::testRenderWritesTheUnitFirstcallsTrimTest::testRenderWritesEachFormcallsWeightStringParametersTest::testRenderWritesTheNumberscallsWeightStringTest::testRenderWritesTheCastAndTheLevelscallsFrameBoundTest::testRenderWritesTheOffsetAndTheKindcallsWindowFunctionTest::testRenderWritesTheOptionsBeforeTheWindowcallsWindowSpecTest::testRenderWritesThePartscallsOpenHandlerTest::testDeriveRelationIsOpencallsInsertSetTest::testRenderRejectsAColumnListcallsDefaultOfColumnTest::testDeriveScalarHasTheFactsOfTheColumncallsDefaultOfColumnTest::testRenderGluesTheParenthesiscallsFullTextSearchTest::testAPredicateSearchStringIsRejectedcallsFullTextSearchTest::testASearchStringThatTakesTheBooleanModeIsRejectedcallsFullTextSearchTest::testDeriveScalarIsADoubleRelevancecallsFullTextSearchTest::testRenderWritesTheColumnsInParenthesesAndTheModecallsInsertedColumnTest::testDeriveScalarCanAlwaysBeNullcallsInsertedColumnTest::testRenderGluesTheParenthesiscallsJsonExtractionTest::testAHexadecimalPathIsRejectedcallsJsonExtractionTest::testDeriveScalarIsJsonOrTextThatCanBeNullcallsJsonExtractionTest::testRenderWritesTheOperatorcallsComparisonTest::testAComparisonAsRightOperandIsRejectedcallsComparisonTest::testRenderWritesTheOperandsAroundTheOperatorInTheOrderWrittencallsOrderItemTest::testRenderKeepsAnAscendingDirectionThatWasWrittencallsOrderItemTest::testRenderOmitsTheDirectionWhenNoneWasWrittencallsOrderItemTest::testRenderWritesTheExpressionAndTheDirectioncallsSelectExpressionTest::testRenderWritesTheExpressionAndTheAliascallsSelectTest::testANodeUsedAtTwoPositionsIsRejectedcallsSelectTest::testRenderBuildsSqlFromAnExplicitStructurecallsSetOperationTest::testALastOperandWithItsOwnOrderingIsRejectedcallsBlockTest::testDeriveProgramHidesAParameterWithAVariableOfTheSameNamecallsBlockTest::testDeriveProgramKeepsTheFirstMeaningOfADuplicateVariablecallsReturnStatementTest::testDeriveProgramResolvesTheParametercallsSimpleCaseTest::testDeriveProgramDerivesTheOperandAndEveryBranchcalls
Relations§
Instantiated in 1
Constant reads 1
Type checks 14
- instanceof SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts::open() packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:144
- instanceof SqlSemantics\Platform\MySql\Rules\Dml\LoadFacts::derive() packages/sql-semantics-mysql/src/Rules/Dml/LoadFacts.php:39
- instanceof SqlSemantics\Platform\MySql\Rules\Query\Having\HavingScope::grouping() packages/sql-semantics-mysql/src/Rules/Query/Having/HavingScope.php:68
- 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:95
- 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\ItemNaming::name() packages/sql-semantics-mysql/src/Rules/Query/ItemNaming.php:113
- instanceof SqlSemantics\Platform\MySql\Rules\Query\ItemNaming::own() packages/sql-semantics-mysql/src/Rules/Query/ItemNaming.php:138
- instanceof SqlSemantics\Platform\MySql\Rules\Query\SelectFacts::aliases() packages/sql-semantics-mysql/src/Rules/Query/SelectFacts.php:127
- instanceof SqlSemantics\Platform\MySql\Rules\Query\SortScopes::word() packages/sql-semantics-mysql/src/Rules/Query/SortScopes.php:98
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\ViewColumns::generated() packages/sql-semantics-mysql/src/Rules/TableDefinition/ViewColumns.php:116
- instanceof SqlSemantics\Platform\MySql\Statement\Alter\Command\Reorder::__construct() packages/sql-semantics-mysql/src/Statement/Alter/Command/Reorder.php:46
- instanceof SqlSemantics\Platform\MySql\Statement\Dml\Insert\ColumnList::__construct() packages/sql-semantics-mysql/src/Statement/Dml/Insert/ColumnList.php:44
- instanceof SqlSemantics\Platform\MySql\Statement\Dml\Load\LoadTable::__construct() packages/sql-semantics-mysql/src/Statement/Dml/Load/LoadTable.php:99
Type declarations 7
- type SqlSemantics\Platform\MySql\Lowering\Leaf\NameRule packages/sql-semantics-mysql/src/Lowering/Leaf/NameRule.php:237
- type SqlSemantics\Platform\MySql\Rules\Dml\WriteScope packages/sql-semantics-mysql/src/Rules/Dml/WriteScope.php:41
- type SqlSemantics\Platform\MySql\Rules\Query\ItemNaming packages/sql-semantics-mysql/src/Rules/Query/ItemNaming.php:131
- type SqlSemantics\Platform\MySql\Statement\Dml\Assignment packages/sql-semantics-mysql/src/Statement/Dml/Assignment.php:33
- type SqlSemantics\Platform\MySql\Statement\Expression\Access\DefaultOfColumn packages/sql-semantics-mysql/src/Statement/Expression/Access/DefaultOfColumn.php:37
- type SqlSemantics\Platform\MySql\Statement\Expression\Access\InsertedColumn packages/sql-semantics-mysql/src/Statement/Expression/Access/InsertedColumn.php:39
- type SqlSemantics\Platform\MySql\Statement\Expression\Access\JsonExtraction packages/sql-semantics-mysql/src/Statement/Expression/Access/JsonExtraction.php:48