Skip to content

[BUG] JSQLParser Version 5.3: Statements parsing in versions 5.1 & 5.2, but not in 5.3 #2242

@nick-redfearn

Description

@nick-redfearn

Failing SQL Feature:

This SQL parses fine for me in versions 5.1 + 5.2, but not in 5.3

INSERT INTO foo(col1, col2, col3, col4, col5, col6)
VALUES ((SELECT blah FROM bar INNER JOIN bam ON bar.col1 = bam.col1 WHERE bar.id = ? AND et.id = ?), ?, ?, ?, ?, ?)
ON CONFLICT (id) DO UPDATE
SET col4 = ?, col5 = ?, col6 = ?

Versions 5.1 & 5.2

Image

5.3

Image

Exception

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

Was expecting one of:

    ")"

Context
We are using JSQlParser version 5.2 and are looking at bumping to use 5.3, but we have discovered SQL statements now not parsing

Test Code

  @Test
  void blahblah() throws JSQLParserException {
    String sqlStr = """
      INSERT INTO foo(col1, col2, col3, col4, col5, col6)
      VALUES ((SELECT blah FROM bar INNER JOIN bam ON bar.col1 = bam.col1 WHERE bar.id = ? AND et.id = ?), ?, ?, ?, ?, ?)
      ON CONFLICT (id) DO UPDATE
      SET col4 = ?, col5 = ?, col6 = ?
    """;
    Statement statement = CCJSqlParserUtil.parse(sqlStr);
    System.out.println(statement.toString());
    Insert insert = (Insert) statement;
    assertThat(insert.getTable().toString()).isEqualTo("foo");
  }

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions