Skip to content

[BUG] JSQLParser Version 5.0 : PostgreSQL : TRUNCATE statements do not parse with multiple tables provided #2047

Closed

Description

@nick-redfearn

Failing SQL Feature:

TRUNCATE or TRUNCATE TABLE statements do not parse with multiple tables provided

This is allowed by PostgreSQL:
https://www.postgresql.org/docs/current/sql-truncate.html

TRUNCATE [ TABLE ] [ ONLY ] name [ * ] [, ... ]
    [ RESTART IDENTITY | CONTINUE IDENTITY ] [ CASCADE | RESTRICT ]

SQL Example:

TRUNCATE table1, table2, table3

OR

TRUNCATE TABLE table1, table2, table3

These both fail with the error message below

net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," ","
    at line 2, column 11.

Was expecting one of:

    "CASCADE"
    <EOF>
    <ST_SEMICOLON>

Software Information:

  • JSqlParser version 5.0
  • PostgreSQL

Activity

  1. manticore-projects commented on Jul 24, 2024

    @manticore-projects
    Contributor

    Greetings.

    Correct, the current implementation covers single table truncate only.
    You would need to provide or sponsor an implementation for multiple table truncate to make it happen.

  2. manticore-projects commented on Jul 24, 2024

    @manticore-projects
    Contributor

    Duplicate #1821

  3. nick-redfearn commented on Jul 24, 2024

    @nick-redfearn
    ContributorAuthor

    @manticore-projects I've created this pull request -> #2048

  4. manticore-projects commented on Jul 26, 2024

    @manticore-projects
    Contributor

    Fixed via #2048

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions