Skip to content

[BUG] JSQLParser 5.3 : MySQL : Cannot parse DROP COLUMN where "type" is the column name #2447

Description

@minleejae

Failing SQL Feature:

  • Cannot parse ALTER TABLE ... DROP COLUMN command where type is the column name
  • TYPE is a non-reserved keyword in MySQL 8.0 (see MySQL keyword list), so ALTER TABLE nullable_tbl DROP COLUMN type; is valid MySQL syntax without any quoting

SQL Example:

ALTER TABLE nullable_tbl DROP COLUMN type;

fails with:

net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "type" "TYPE"
    at line 1, column 38.

Was expecting one of:

    "IF"
    "NAME"
    <S_IDENTIFIER>
    <S_QUOTED_IDENTIFIER>

while the same identifier parses fine in other contexts:

SELECT type FROM nullable_tbl;                  -- OK
ALTER TABLE nullable_tbl DROP COLUMN `type`;    -- OK (quoted)

Software Information:

  • JSQLParser 5.3 (also reproducible with current master: KeywordOrIdentifier() accepts K_NAME | K_NEXT | K_VALUE | K_PUBLIC | K_STRING | K_DATA but not K_TYPE)
  • MySQL

Tips:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions