classNameArgument
final class NameArgument
implements AttributeArgument
uses Snapshot
@visibility public.An attribute value read as the name of an object of a fixed kind, such as the function of an operator.
defGetQualifiedName accepts a name written as a type name, an operator, a string (one name, as written) or a reserved keyword (one name, in lower case). A plain, possibly qualified, name is kept as a dotted name. A name written with type modifiers, array bounds, SETOF, %TYPE or as a type keyword is kept as that type name, of which the server reads only the names: a type keyword such as integer names pg_catalog.int4. The kind is the object the command looks the name up as; for multirange_type_name it is the type the command creates. Source: https://www.postgresql.org/docs/17/sql-createoperator.html, defGetQualifiedName in src/backend/commands/define.c of PostgreSQL 17.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE OPERATOR === (rightarg = int4, function = pg_catalog.int4eq)');
$function = $operation->statement->definition[1]->value;
[$function->kind->value, array_map(static fn ($part) => $part->value, $function->parts())] // => ['FUNCTION', ['pg_catalog', 'int4eq']]new \SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\NameArgument(\SqlSemantics\Platform\PostgreSql\Statement\Name\ObjectKind::Function, new \SqlSemantics\Platform\PostgreSql\Statement\Type\TypeName(new \SqlSemantics\Platform\PostgreSql\Statement\Type\Designation\NamedDesignation(new \SqlSemantics\Platform\PostgreSql\Statement\Name\DottedName([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('f')])))) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public ObjectKind $kindpublic DottedName|TypeName|OperatorName|StringConstant|KeywordWord $nameMethods§
public function __construct(
public ObjectKind $kind,
public DottedName|TypeName|OperatorName|StringConstant|KeywordWord $name,
)Parameters
$kind | ObjectKind | The kind of object the name stands for |
$name | DottedName|TypeName|OperatorName|StringConstant|KeywordWord | The name as written |
Calls 5
- static-call Check::input() line 55
- function-call
in_arrayline 55 - static-call Reading::kinds() line 55
- method-call AttributeReader::plain() line 56
- new AttributeReader line 56
public function parts(): non-empty-list<Name>Answers the names the server reads, from the outermost qualifier to the object name.
Returns
non-empty-list<Name>Test cases 1
Calls 3
- method-call ArgumentText::names() line 70
- new ArgumentText line 70
- new Name line 72
public function fits(Reading $reading): boolTells whether the reading looks up an object of this kind.
Parameters
$reading | Reading |
Returns
boolTest cases 1
Calls 1
- method-call Reading::kind() line 82
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the modifier expressions of a name written as a type name.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 1
public function render(Output $out): voidWrites the name as written; a dotted name is written where the grammar reads a type name.
Parameters
$out | Output |
Test cases 2
Calls 4
- method-call Spelling::dotted() line 99
- new Spelling line 99
- class-const NameUse::Routine() line 99
- method-call Output::node() line 103
Test cases 18§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
NameArgumentTest::testDeriveClauseDerivesTheModifiersOfATypeNamecallsNameArgumentTest::testFitsAReadingOfTheSameKindcallsNameArgumentTest::testPartsAnswersTheNamesTheServerReadscallsNameArgumentTest::testRejectsAKindNoAttributeNamescallsNameArgumentTest::testRejectsAPlainTypeNamecallsNameArgumentTest::testRenderWritesADottedNameWhereATypeNameIsReadcallsNameArgumentTest::testRenderWritesOtherSpellingsAsWrittencalls
Other tests reaching this symbol 11
OperatorClassRuleTest::testChangesLowersAnAttributeWithoutValueAndNonecallsAttributeReaderTest::testAttributeReadsARecognizedNameAndKeepsAnotherAsWrittencallsAttributeReaderTest::testNameUnwrapsAPlainTypeNameAndRejectsNumberscallsCreateRangeTest::testDeriveStatementReadsTheAttributescallsAttributeArgumentTest::testAReadValueIsNotAWrittenOptionValuecallsAttributeArgumentTest::testEveryReadValueIsAnAttributeArgumentcallsAttributeTest::testDeriveClauseDerivesTheValuecallsAttributeTest::testRejectsAMemberOfAnotherNamecallsAttributeTest::testRejectsAValueReadAnotherWaycallsAttributeTest::testRenderWritesTheNameAsALabelAndTheValuecallsDefineTest::testDeriveStatementReadsTheFunctionOfAnOperatorAsARoutinecalls