Skip to content

MySQL ALTER TABLE FIRST #2232

@brainsiq

Description

@brainsiq

Describe the bug
The parser is unable to parse MySQL alter table statements with the FIRST qualifier to position as the first column in the table.

Database Engine
MySQL 8

To Reproduce
Example SQL: ALTER TABLE product MODIFY COLUMN type enum('one','two') NOT NULL FIRST
Package version: 5.3.4
Node version: 20

Adding this SQL to your test suite results in the following error:

SyntaxError: Expected "#", "'", "", "--", "/", """, "`", [ \t\n\r], [0-9], or [A-Za-z_一-龥] but end of input found.

Expected behavior
The SQL should be parsed.

When we use AFTER we get a suffix object in the result such as

suffix: {
  keyword: 'AFTER',
  expr: { type: 'column_ref', table: null, column: 'the_column_before' }
},

With FIRST I mgiht expect the following

suffix: {
  keyword: 'FIRST'
},

Screenshots
N/A

Additional context

MySQL ALTER TABLE docs: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions