final class Rename
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

ALTER kind object RENAME [part name] TO new_name: renames an object or one of its columns, constraints or attributes.

Mirrors PostgreSQL's RenameStmt (renameType, relationType, object, subname, newname, behavior, missing_ok). How the object is named depends on the kind (PG-OBJECT-FORM-001). A renamed relation is resolved; renaming a column the declared relation lacks, or to a name it has, is reported. Renaming changes no declaration of the context. Source: https://www.postgresql.org/docs/17/sql-altertable.html, https://www.postgresql.org/docs/17/sql-alterfunction.html.

Reading a column renamedoctest
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER TABLE t RENAME COLUMN a TO b');
    [$operation->statement->member?->name->value, $operation->statement->newName->value] // => ['a', 'b']

Properties§

public ObjectKind $kind
public Name $newName
public RenamedMember|null $member = null
public bool $ifExists = false
public DropBehavior|null $behavior = null
public RoleWord|null $roleWord = null

Methods§

public function __construct(
    public ObjectKind $kind,
    public ObjectReference $object,
    public Name $newName,
    public RenamedMember|null $member = null,
    public bool $ifExists = false,
    public DropBehavior|null $behavior = null,
    public RoleWord|null $roleWord = null,
)

Parameters

$kindObjectKindThe kind of the object
$objectObjectReferenceThe object, named as ALTER ... RENAME names objects of the kind
$newNameNameThe new name
$memberRenamedMember|nullThe renamed column, constraint or attribute, if the object itself is not renamed
$ifExistsboolWhether IF EXISTS is written
$behaviorDropBehavior|nullCASCADE or RESTRICT, written only when renaming an attribute
$roleWordRoleWord|nullThe keyword naming a role; given exactly for roles
Calls 12
public function deriveStatement(Derivation $derivation): void

Derives the object and reports a renamed column the declared relation lacks or a new column name it has.

Parameters

$derivationDerivation
Calls 9
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 5

Test cases 7§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 6
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Type declarations 1