classObjectForms
final class ObjectForms
Tells which object name forms each generic object command writes for each object kind.
Rule: PG-OBJECT-FORM-001. Scope: DropStmt, RemoveFuncStmt, RemoveAggrStmt, RemoveOperStmt, DropOpClassStmt, DropOpFamilyStmt, CommentStmt, SecLabelStmt, RenameStmt, AlterObjectSchemaStmt, AlterOwnerStmt, AlterObjectDependsStmt and the DROP CAST and DROP TRANSFORM forms of the catalog family. The grammar fixes, per command and object kind, how the object is named: a dotted name of any length, a single name, a name within a table or domain, a type name, a routine, aggregate or operator signature, a name with an access method, a cast, a transform, a large-object number or a relation name. A constructor accepts exactly the pairs these tables list, so every command it builds can be written back. Source: the synopses of https://www.postgresql.org/docs/17/sql-commands.html. Status: Implemented.
Constants§
public const ANY_NAME = ['TABLE', 'SEQUENCE', 'VIEW', 'MATERIALIZED VIEW', 'INDEX', 'FOREIGN TABLE', 'C…The kinds object_type_any_name writes with a dotted name.
public const DROP_NAME = ['ACCESS METHOD', 'EVENT TRIGGER', 'EXTENSION', 'FOREIGN DATA WRAPPER', 'LANGUA…The kinds drop_type_name writes with a single name.
public const GLOBAL_NAME = ['DATABASE', 'ROLE', 'SUBSCRIPTION', 'TABLESPACE']The kinds object_type_name adds to drop_type_name.
public const MEMBER = ['POLICY', 'RULE', 'TRIGGER']The kinds named within a table: object_type_name_on_any_name.
public const ROUTINE = ['FUNCTION', 'PROCEDURE', 'ROUTINE']The routine kinds written with function_with_argtypes.
public const SINGLE_DROP = ['POLICY', 'RULE', 'TRIGGER', 'OPERATOR CLASS', 'OPERATOR FAMILY', 'CAST', 'TRA…The kinds DROP removes one object of at a time.
public const RELATION = ['TABLE', 'VIEW', 'MATERIALIZED VIEW', 'FOREIGN TABLE']The kinds whose objects are relations the context can declare: a command naming one resolves it.
public const ALTERED_RELATION = ['TABLE', 'FOREIGN TABLE', 'SEQUENCE', 'VIEW', 'MATERIALIZED VIEW', 'INDEX']The kinds ALTER ... RENAME, SET SCHEMA and DEPENDS ON EXTENSION write with a relation name; TABLE and FOREIGN TABLE accept ONLY.
Methods§
public function form(ObjectReference $object): stringAnswers the form code of an object reference.
Parameters
$object | ObjectReference |
Returns
stringTest cases 1
Called from 7
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\ChangeOwner::__construct() packages/sql-semantics-postgres/src/Statement/Object/ChangeOwner.php:42
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Comment::__construct() packages/sql-semantics-postgres/src/Statement/Object/Comment.php:44
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Drop::__construct() packages/sql-semantics-postgres/src/Statement/Object/Drop.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\ExtensionDependency::__construct() packages/sql-semantics-postgres/src/Statement/Object/ExtensionDependency.php:45
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::__construct() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:62
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\SecurityLabel::__construct() packages/sql-semantics-postgres/src/Statement/Object/SecurityLabel.php:49
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\SetSchema::__construct() packages/sql-semantics-postgres/src/Statement/Object/SetSchema.php:46
public function drop(ObjectKind $kind): list<string>Answers the forms DROP writes for a kind.
Parameters
$kind | ObjectKind |
Returns
list<string>Test cases 1
Called from 1
Calls 6
- function-call
in_arrayline 114 - class-const ObjectForms::ANY_NAME() line 114
- class-const ObjectForms::DROP_NAME() line 115
- class-const ObjectForms::MEMBER() line 116
- class-const ObjectForms::ROUTINE() line 117
- method-call ObjectForms::common() line 118
public function comment(ObjectKind $kind): list<string>Answers the forms COMMENT ON writes for a kind.
Parameters
$kind | ObjectKind |
Returns
list<string>Test cases 1
Called from 1
Calls 9
- function-call
in_arrayline 132 - class-const ObjectForms::ANY_NAME() line 132
- class-const ObjectForms::DROP_NAME() line 133
- class-const ObjectForms::GLOBAL_NAME() line 133
- class-const ObjectForms::MEMBER() line 134
- class-const ObjectForms::ROUTINE() line 135
- class-const ObjectKind::DomainConstraint() line 136
- class-const ObjectKind::LargeObject() line 137
- method-call ObjectForms::common() line 138
public function label(ObjectKind $kind): list<string>Answers the forms SECURITY LABEL writes for a kind.
Parameters
$kind | ObjectKind |
Returns
list<string>Test cases 1
Called from 1
Calls 9
- function-call
in_arrayline 152 - class-const ObjectForms::ANY_NAME() line 152
- class-const ObjectForms::DROP_NAME() line 153
- class-const ObjectForms::GLOBAL_NAME() line 153
- class-const ObjectForms::ROUTINE() line 154
- class-const ObjectKind::LargeObject() line 155
- class-const ObjectKind::Type() line 156
- class-const ObjectKind::Domain() line 156
- class-const ObjectKind::Aggregate() line 157
public function common(ObjectKind $kind): list<string>Answers the forms the type, aggregate, operator, operator class and family, cast and transform kinds share in DROP and COMMENT.
Parameters
$kind | ObjectKind |
Returns
list<string>Test cases 1
Called from 2
Calls 8
- class-const ObjectKind::Type() line 170
- class-const ObjectKind::Domain() line 170
- class-const ObjectKind::Aggregate() line 171
- class-const ObjectKind::Operator() line 172
- class-const ObjectKind::OperatorClass() line 173
- class-const ObjectKind::OperatorFamily() line 173
- class-const ObjectKind::Cast() line 174
- class-const ObjectKind::Transform() line 175
public function altered(ObjectKind $kind, string $command): list<string>Answers the forms ALTER ... RENAME, SET SCHEMA and OWNER TO write for a kind, by command.
Parameters
$kind | ObjectKind | |
$command | string | `rename`, `schema` or `owner` |
Returns
list<string>Test cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\ChangeOwner::__construct() packages/sql-semantics-postgres/src/Statement/Object/ChangeOwner.php:42
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::__construct() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:62
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\SetSchema::__construct() packages/sql-semantics-postgres/src/Statement/Object/SetSchema.php:46
Calls 6
- function-call
in_arrayline 196 - class-const ObjectForms::ROUTINE() line 198
- class-const ObjectKind::Aggregate() line 199
- class-const ObjectKind::OperatorClass() line 200
- class-const ObjectKind::OperatorFamily() line 200
- method-call ObjectForms::alteredRest() line 201
public function alteredRest(ObjectKind $kind, string $command): list<string>Answers the forms of the relation, operator, member and large-object kinds of ALTER ... RENAME, SET SCHEMA and OWNER TO.
Parameters
$kind | ObjectKind | |
$command | string | `rename`, `schema` or `owner` |
Returns
list<string>Called from 1
Calls 8
- function-call
in_arrayline 214 - class-const ObjectForms::ALTERED_RELATION() line 214
- class-const ObjectKind::Index() line 214
- class-const ObjectKind::Table() line 217
- class-const ObjectKind::ForeignTable() line 217
- class-const ObjectForms::MEMBER() line 218
- class-const ObjectKind::Operator() line 219
- class-const ObjectKind::LargeObject() line 220
public function depends(ObjectKind $kind): list<string>Answers the forms ALTER ... DEPENDS ON EXTENSION writes for a kind.
Parameters
$kind | ObjectKind |
Returns
list<string>Test cases 1
Called from 1
Calls 6
- class-const ObjectKind::Function() line 233
- class-const ObjectKind::Procedure() line 233
- class-const ObjectKind::Routine() line 233
- class-const ObjectKind::Trigger() line 234
- class-const ObjectKind::MaterializedView() line 235
- class-const ObjectKind::Index() line 235
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
ObjectFormsTest::testAlteredDependsOnTheCommandcallsObjectFormsTest::testAlteredRestCoversRelationsOperatorsMembersAndLargeObjectscallsObjectFormsTest::testCommentAddsColumnsConstraintsAndLargeObjectscallsObjectFormsTest::testCommonCoversTheSignedKindscallsObjectFormsTest::testDependsAcceptsSixKindscallsObjectFormsTest::testDropFollowsTheKindNonterminalscallsObjectFormsTest::testFormNamesEachReferencecallsObjectFormsTest::testLabelAcceptsFewerKindscalls
Relations§
Instantiated in 7
- new SqlSemantics\Platform\PostgreSql\Statement\Object\ChangeOwner::__construct() packages/sql-semantics-postgres/src/Statement/Object/ChangeOwner.php:41
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Comment::__construct() packages/sql-semantics-postgres/src/Statement/Object/Comment.php:43
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Drop::__construct() packages/sql-semantics-postgres/src/Statement/Object/Drop.php:62
- new SqlSemantics\Platform\PostgreSql\Statement\Object\ExtensionDependency::__construct() packages/sql-semantics-postgres/src/Statement/Object/ExtensionDependency.php:44
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::__construct() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:61
- new SqlSemantics\Platform\PostgreSql\Statement\Object\SecurityLabel::__construct() packages/sql-semantics-postgres/src/Statement/Object/SecurityLabel.php:48
- new SqlSemantics\Platform\PostgreSql\Statement\Object\SetSchema::__construct() packages/sql-semantics-postgres/src/Statement/Object/SetSchema.php:45
Method calls 14
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\ChangeOwner::__construct() packages/sql-semantics-postgres/src/Statement/Object/ChangeOwner.php:42
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\ChangeOwner::__construct() packages/sql-semantics-postgres/src/Statement/Object/ChangeOwner.php:42
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Comment::__construct() packages/sql-semantics-postgres/src/Statement/Object/Comment.php:44
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Comment::__construct() packages/sql-semantics-postgres/src/Statement/Object/Comment.php:44
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Drop::__construct() packages/sql-semantics-postgres/src/Statement/Object/Drop.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Drop::__construct() packages/sql-semantics-postgres/src/Statement/Object/Drop.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\ExtensionDependency::__construct() packages/sql-semantics-postgres/src/Statement/Object/ExtensionDependency.php:45
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\ExtensionDependency::__construct() packages/sql-semantics-postgres/src/Statement/Object/ExtensionDependency.php:45
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::__construct() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:62
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::__construct() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:62
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\SecurityLabel::__construct() packages/sql-semantics-postgres/src/Statement/Object/SecurityLabel.php:49
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\SecurityLabel::__construct() packages/sql-semantics-postgres/src/Statement/Object/SecurityLabel.php:49
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\SetSchema::__construct() packages/sql-semantics-postgres/src/Statement/Object/SetSchema.php:46
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\SetSchema::__construct() packages/sql-semantics-postgres/src/Statement/Object/SetSchema.php:46
Constant reads 4
- class-const SqlSemantics\Platform\PostgreSql\Rules\Routine\RelationTargets::resolve() packages/sql-semantics-postgres/src/Rules/Routine/RelationTargets.php:60
- class-const SqlSemantics\Platform\PostgreSql\Statement\Object\Drop::__construct() packages/sql-semantics-postgres/src/Statement/Object/Drop.php:66
- class-const SqlSemantics\Platform\PostgreSql\Statement\Object\Rename::__construct() packages/sql-semantics-postgres/src/Statement/Object/Rename.php:64
- class-const SqlSemantics\Platform\PostgreSql\Statement\Object\SetSchema::__construct() packages/sql-semantics-postgres/src/Statement/Object/SetSchema.php:47