-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hello, I came across bug when creating new instance of AlterTableCommand from old one.
$actions = getMeNewActions($originalCommand);
$newCommand = new AlterTableCommand(
$originalCommand->getTable(),
$actions,
$originalCommand->getAlterOptions(),
$originalCommand->getOptionsList(), // this causes the problem
$originalCommand->getPartitioning(),
);Problem is with AlterTableCommand::getOptionsList().
public function getOptionsList(): TableOptionsList
{
return $this->tableOptions ?? new TableOptionsList([]);
}This would not be problematic itself if serialization of AlterTableCommand did not depend on null check:
// in AlterTableCommand::serialize() line 127
if ($this->tableOptions !== null) {
if (!$this->actions->isEmpty()) {
$result .= ',';
}
$result .= "\n" . $formatter->indent . $this->tableOptions->serialize($formatter, ",\n", ' ');
}The logic should probably check if the TableOptionsList is empty so the comma + \n + indent there is not added without reason since empty TableOptionsList serializes to ''.
Metadata
Metadata
Assignees
Labels
No labels