XF\Db\Schema\Column::values() can generate invalid SQL

Xon

Well-known member
Affected version
2.2.13
Given the example code:
PHP:
$this->schemaManager()->createTable('test', function(Create $table) {
    $table->addColumn('id','int')->values(null);
});

It will generate the following (invalid) SQL:
SQL:
  CREATE TABLE `test` (
        `id` INT(NULL) UNSIGNED NOT NULL
);

The issue is XF\Db\Schema\Column::values(), doesn't handle null sanely, and converts it into [null] unlike all the other fluent functions for XF\Db\Schema\Column

SQL:
public function values($values)
{
    if (!is_array($values))
    {
        $values = [$values];
    }
    $this->values = $values;

    $this->length = null;

    return $this;
}
 
Top Bottom