Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
susnux opened this issue Aug 13, 2024 · 0 comments
Open

Comments

@susnux
Copy link

susnux commented Aug 13, 2024

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant