Skip to content

Parser fails when using some keywords as column names #317

Closed
@elliot2extreme

Description

@elliot2extreme

Parsing the following statement will result in an error

new Parser('ALTER TABLE `demo` ADD KEY `IDX_REPAIR` (`REPAIR`);', true);

Problem is the check

elseif (! empty(Parser::$STATEMENT_PARSERS[$token->value]))

in the parse function in AlterOperation class. But as far as I understand it is allowed to use keywords as column names if you quote them.

How can we fix the problem? The easiest would be just to remove the check in the parse function. Another one would be to add an additional attribute to a token which tells if it was quoted. In case this is true, keywords are allowed as names and we skip the additional statement error checks in the parser for that token. What do you think?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions