classAttribute
final class Attribute
implements Clause
uses Snapshot
@visibility public.One attribute of a definition, name or name = value, as the defining command reads it.
Mirrors PostgreSQL's DefElem together with the meaning its command gives it. A recognized attribute names the member of the command's attribute set and holds its value read the way the command reads it, such as a routine name for function or a type for leftarg. The value stays as written when the command does not read it: for an attribute the command does not recognize, for an option of a text search template, for an obsolete attribute whose value is ignored, and for a value the command rejects, such as a number where it expects a name. Source: https://www.postgresql.org/docs/17/sql-createoperator.html, src/backend/commands/define.c of PostgreSQL 17.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE OPERATOR === (leftarg = int4, rightarg = int4, function = int4eq)');
$attribute = $operation->statement->definition[2];
[$attribute->known, $attribute->value->kind] // => [\SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Known\OperatorAttribute::Function, \SqlSemantics\Platform\PostgreSql\Statement\Name\ObjectKind::Function]new \SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Attribute(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('function'), \SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Known\OperatorAttribute::Function, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\StringConstant('int4eq')) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public Name $namepublic KnownAttribute|null $knownpublic AttributeArgument|TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null $value = nullMethods§
public function __construct(
public Name $name,
public KnownAttribute|null $known,
public AttributeArgument|TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null $value = null,
)Parameters
$name | Name | The attribute name as written, decoded |
$known | KnownAttribute|null | The member of the command's attribute set the name is; null when the command does not recognize the name |
$value | AttributeArgument|TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null | The value as the command reads it, or as written when the command does not read it; null when given alone |
Calls 3
- static-call Check::input() line 57
- method-call AttributeReader::read() line 61
- new AttributeReader line 61
public function valued(): boolTells whether a value is written after the name.
Returns
boolTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Attribute::render() packages/sql-semantics-postgres/src/Statement/Object/Attribute/Attribute.php:87
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\AttributeChange::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/AttributeChange.php:41
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the value, which may hold type modifier expressions.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 1
public function render(Output $out): voidWrites the name and the value.
Parameters
$out | Output |
Test cases 1
Calls 4
- method-call Output::name() line 86
- class-const NameUse::Label() line 86
- method-call Attribute::valued() line 87
- method-call Output::symbol() line 88
Test cases 26§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
AttributeTest::testAcceptsAWrittenValueTheCommandRejectscallsAttributeTest::testDeriveClauseDerivesTheValuecallsAttributeTest::testRejectsAMemberOfAnotherNamecallsAttributeTest::testRejectsAReadValueOfAnUnrecognizedAttributecallsAttributeTest::testRejectsAValueReadAnotherWaycallsAttributeTest::testRejectsAWrittenValueTheCommandReadscallsAttributeTest::testRenderWritesTheNameAsALabelAndTheValuecallsAttributeTest::testValuedTellsWhetherAValueIsWrittencalls
Other tests reaching this symbol 18
AttributeChecksTest::testUnrecognizedAnswersNothingForATemplateOptioncallsAttributeChecksTest::testValueReportsWhatTheCommandChecksOnAReadValuecallsChangeChecksTest::testProblemAcceptsARemovedFunctioncallsDefineChecksTest::testAggregateReportsMovingSerializationHypotheticalAndBaseTypecallsDefineChecksTest::testBaseTypeReportsTheMissingOutputFunctioncallsDefineChecksTest::testCollationFollowsTheProvidercallsDefineChecksTest::testOperatorTellsAMissingRightArgumentFromMissingArgumentscallsDefineChecksTest::testPresentKeepsTheLastRecognizedAttributeOfEachNamecallsDefineChecksTest::testProvidedReportsWhatOnlyIcuTakescallsDefineChecksTest::testSearchReportsAConfigurationWithParserAndCopycallsCreateRangeTest::testRejectsAnAttributeOfAnotherCommandcallsDefineTest::testDeriveStatementReadsTheFunctionOfAnOperatorAsARoutinecallsDefineTest::testRejectsAnAttributeOfAnotherCommandcallsDefineTest::testRejectsAnOldStyleAttributeWithoutValuecallsDefineTest::testRejectsAnOperatorNamedByADottedNamecallsDefineTest::testRejectsAnUnrecognizedAttributeTheCommandKnowscallsDefineTest::testRejectsReplaceOfAnotherKindcallsAlterOperatorTest::testRejectsAnAttributeOfAnotherCommandcalls
Relations§
Instantiated in 1
Method calls 2
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\AttributeChange::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/AttributeChange.php:41
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\AttributeChange::deriveClause() packages/sql-semantics-postgres/src/Statement/Object/Attribute/AttributeChange.php:49
Constant reads 2
- class-const SqlSemantics\Platform\PostgreSql\Statement\Catalog\Type\CreateRange::__construct() packages/sql-semantics-postgres/src/Statement/Catalog/Type/CreateRange.php:49
- class-const SqlSemantics\Platform\PostgreSql\Statement\Object\Define::__construct() packages/sql-semantics-postgres/src/Statement/Object/Define.php:71
Type declarations 5
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeChecks packages/sql-semantics-postgres/src/Rules/Routine/AttributeChecks.php:99
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeChecks packages/sql-semantics-postgres/src/Rules/Routine/AttributeChecks.php:109
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:91
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\ChangeChecks packages/sql-semantics-postgres/src/Rules/Routine/ChangeChecks.php:58
- type SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\AttributeChange packages/sql-semantics-postgres/src/Statement/Object/Attribute/AttributeChange.php:39