classDefaultSetting
final class DefaultSetting
implements AlterCommand
uses Snapshot
Public API: explicitly declared with
@visibility public.ALTER [COLUMN] c SET DEFAULT value, SET DEFAULT (expression) or DROP DEFAULT: a request to change the default of a column.
Mirrors PT_alter_table_set_default; no value means DROP DEFAULT. A literal default and a parenthesized expression default (8.0.13 and later) differ: the server stores the first as a constant and evaluates the second for each row, so the form is kept. The value is 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/data-type-defaults.html, https://dev.mysql.com/doc/refman/8.4/en/alter-table.html.
$alter = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('ALTER TABLE t ALTER a SET DEFAULT 1');
[$alter->statement->commands[0]->expression, $alter->toString()] // => [false, 'ALTER TABLE t ALTER COLUMN a SET DEFAULT 1']Properties§
public ColumnName $columnpublic Scalar|null $valuepublic bool $expression = falseMethods§
public function __construct(
public ColumnName $column,
public Scalar|null $value,
public bool $expression = false,
)Parameters
$column | ColumnName | The column |
$value | Scalar|null | The new default, or null for DROP DEFAULT |
$expression | bool | Whether the default is an expression in parentheses rather than a literal |
Calls 1
- static-call Check::input() line 43
public function deriveCommand(Derivation $derivation, Environment $scope): voidDerives the default value.
Parameters
$derivation | Derivation | |
$scope | Environment |
Calls 1
- method-call Derivation::scalar() line 52
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
DefaultSettingTestcalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Lowering\TableChange\Alter\ColumnItemRule::altered() packages/sql-semantics-mysql/src/Lowering/TableChange/Alter/ColumnItemRule.php:133
- new SqlSemantics\Platform\MySql\Lowering\TableChange\Alter\ColumnItemRule::altered() packages/sql-semantics-mysql/src/Lowering/TableChange/Alter/ColumnItemRule.php:137
- new SqlSemantics\Platform\MySql\Lowering\TableChange\Alter\ColumnItemRule::altered() packages/sql-semantics-mysql/src/Lowering/TableChange/Alter/ColumnItemRule.php:138