Fixed 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;
}
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.16).

Change log:
Avoid generating invalid SQL with XF\Db\Schema\Column::values()
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom