classDropElement
final class DropElement
implements AlterCommand
uses Snapshot
@visibility public.DROP [COLUMN] c [RESTRICT | CASCADE], DROP PRIMARY KEY, DROP FOREIGN KEY, DROP INDEX, DROP CHECK or DROP CONSTRAINT.
Mirrors PT_alter_table_drop and its subclasses: one action with the kind of element. The primary key has no name; every other kind names its element (5.x lets a table qualify the name). RESTRICT and CASCADE are accepted only after a column and have no effect; they are kept as written. Only columns are part of a declaration context, so only a dropped column is checked (see AlterTable). The word COLUMN is optional and always written. Source: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html.
$alter = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('ALTER TABLE t DROP FOREIGN KEY fk');
[$alter->statement->commands[0]->kind, $alter->toString()] // => [\SqlSemantics\Platform\MySql\Statement\Alter\Command\ElementKind::ForeignKey, 'ALTER TABLE t DROP FOREIGN KEY fk']Properties§
public ElementKind $kindpublic ColumnName|null $name = nullpublic DropBehavior|null $behavior = nullMethods§
public function __construct(
public ElementKind $kind,
public ColumnName|null $name = null,
public DropBehavior|null $behavior = null,
)Parameters
$kind | ElementKind | The kind of element |
$name | ColumnName|null | The element name; null only for the primary key |
$behavior | DropBehavior|null | RESTRICT or CASCADE after a column, when written |
Calls 3
- static-call Check::input() line 44
- class-const ElementKind::PrimaryKey() line 44
- class-const ElementKind::Column() line 45
public function deriveCommand(Derivation $derivation, Environment $scope): voidDerives nothing: the action holds no expression.
Parameters
$derivation | Derivation | |
$scope | Environment |
public function render(Output $out): voidWrites the action.
Parameters
$out | Output |
Calls 2
- method-call Output::keyword() line 60
- function-call
explodeline 60
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
DropElementTestcalls