Skip to content

[BUG] JSQLParser Version : 5.3 : Parse error if a column name is keywords in DDL #2434

@luotsheng

Description

@luotsheng

Description:

Call CCJSqlParserUtil#parse function, if a colum name is keywords like 'offset' in DDL that will be throw ParseException: Encountered unexpected token: "offset" "OFFSET"

Error test(jdk21):

public void parseDDLFromSQLite() throws JSQLParserException
{
        final String ddl = """
                CREATE TABLE chatmsg(
                  Id INTEGER PRIMARY KEY AUTOINCREMENT,
                  MsgType INTEGER,
                  offset TEXT
                )
                """;
        var createTable = (CreateTable) CCJSqlParserUtil.parse(ddl);
}

Change "offset" to "offset_1" or other name run success:

public void parseDDLFromSQLite() throws JSQLParserException
{
        final String ddl = """
                CREATE TABLE chatmsg(
                  Id INTEGER PRIMARY KEY AUTOINCREMENT,
                  MsgType INTEGER,
                  offset_1 TEXT
                )
                """;
        var createTable = (CreateTable) CCJSqlParserUtil.parse(ddl);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions