classChangeColumn
final class ChangeColumn
implements AlterCommand
uses Snapshot
@visibility public.CHANGE [COLUMN] old definition or MODIFY [COLUMN] definition, each with [FIRST | AFTER column]: a request to redefine a column.
Mirrors PT_alter_table_change_column, which the server builds for both statements: MODIFY is CHANGE with the old name equal to the new one. The old name is kept when CHANGE writes it, and is absent for MODIFY, whose definition names the column. The expressions of the definition are derived in the scope of the changed table. The word COLUMN is optional and always written. Source: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html#alter-table-redefine-column.
$alter = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('ALTER TABLE t CHANGE a b BIGINT FIRST');
[$alter->statement->commands[0]->column?->column->value, $alter->toString()] // => ['a', 'ALTER TABLE t CHANGE COLUMN a b BIGINT FIRST']Properties§
public ColumnName|null $columnpublic ColumnDefinition $definitionpublic ColumnPosition|null $position = nullMethods§
public function __construct(
public ColumnName|null $column,
public ColumnDefinition $definition,
public ColumnPosition|null $position = null,
)Parameters
$column | ColumnName|null | The column CHANGE redefines, or null for MODIFY |
$definition | ColumnDefinition | The new definition with the new name |
$position | ColumnPosition|null | Where the column goes, when written |
public function changed(): ColumnNameAnswers the name of the column the request redefines.
Returns
public function deriveCommand(Derivation $derivation, Environment $scope): voidDerives the expressions of the definition.
Parameters
$derivation | Derivation | |
$scope | Environment |
Calls 2
- method-call ElementFacts::element() line 58
- new ElementFacts line 58
public function render(Output $out): voidTest cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 2
- new SqlSemantics\Platform\MySql\Lowering\TableChange\Alter\ColumnItemRule::item() packages/sql-semantics-mysql/src/Lowering/TableChange/Alter/ColumnItemRule.php:118
- new SqlSemantics\Platform\MySql\Lowering\TableChange\Alter\ColumnItemRule::item() packages/sql-semantics-mysql/src/Lowering/TableChange/Alter/ColumnItemRule.php:119