doctrine/dbal

[MySql][MariaDB] Adding a new column `period` fails (column name not quoted)

Opened this issue · 0 comments

Bug Report

Q A
Version 3.8.3

Summary

Altering a table by adding a new column named period will fail.
period is not a reserved name, but the combination of add and period is a reserved name (another operation).
ref: MariaDB documentation for ADD PERIOD

Example:

$table->addColumn('period', Types::INTEGER, [
	'notnull' => true,
	'default' => 30,
]);

Current behaviour

Generated SQL:

ALTER TABLE the_table ADD period INT DEFAULT 30 NOT NULL;

Error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your
SQL syntax; check the manual that corresponds to your MariaDB server version for t
he right syntax to use near 'INT DEFAULT 30 NOT NULL' at line 1

How to reproduce

  1. Use MariaDB 10.6
  2. Create a table
  3. Alter the table by adding a column named period

Expected behaviour

The column name should be quoted to prevent this issue, so the generated SQL should look like:

ALTER TABLE the_table ADD `period` INT DEFAULT 30 NOT NULL;