Visitar URL original
[BUG] JSQLParser 5.3 : PostgreSQL : Cannot parse DROP COLUMN command where data is the column name · Issue #2339 · JSQLParser/JSqlParser · GitHub
Skip to content

[BUG] JSQLParser 5.3 : PostgreSQL : Cannot parse DROP COLUMN command where data is the column name #2339

Description

@willneedham93

Failing SQL Feature:

  • Cannot parse DROP COLUMN command where data is the column name
  • ALTER TABLE example DROP COLUMN data; can't be parsed

SQL Example:

  •   ALTER TABLE example DROP COLUMN data;

Software Information:

  • JSQLParser 5.3
  • PostgreSQL

Tips:

Appears that adding a column with name data works ok

Activity

  1. willneedham93 commented on Nov 12, 2025

    @willneedham93
    ContributorAuthor

    Can confirm adding tk=<K_DATA> as a case in the drop table identifier fixes this

  2. manticore-projects commented on Nov 13, 2025

    @manticore-projects
    Contributor

    Greetings.

    According to https://manticore-projects.com/JSQLParser/syntax_snapshot.html#alterexpression we only allow <S_IDENTIFIER> | <S_QUOTED_IDENTIFIER> | "NAME" which excludes any defined token (like <K_DATA>).
    The correct way would be to allow for RelObjName (which allows for all tokens that are not reserved keywords).

    PRs are welcome.

  3. willneedham93 commented on Nov 13, 2025

    @willneedham93
    ContributorAuthor

    Thanks for your time!

    I can see we recently introduced KeywordOrIdentifier() as part of #2203, which appears to be used in other branches of alterexpression.

    Would it be suitable to use that in the DROP branch for consistency and extend to additionally handle the K_DATA token? I have this working with a test case locally and am happy to raise a PR.

    Although I am aware that continually appending tokens to that may not be ideal and refactoring to use RelObjectName may be preferred

  4. manticore-projects commented on Nov 13, 2025

    @manticore-projects
    Contributor

    KeywordOrIdentifier() is not sufficient.
    You need RelObjectName instead.

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