Skip to content

[BUG] JSQLParser Version 4.6 : PostgreSQL : Encountered unexpected token: "," "," when parse upsert sql #1749

Closed
@ilxqx

Description

@ilxqx

Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram

Failing SQL Feature:

I use the plain PostgreSQL upsert syntax.

SQL Example:

  • Simplified Query Example, focusing on the failing feature
    INSERT INTO re_rule_mapping ( id, created_time, last_modified_time, rule_item_id, department_id, scene, operation )
                VALUES
                    ( '1', now( ), now( ), '1', '11', 'test', 'stop7' ),
                    ( '2', now( ), now( ), '2', '22', 'test2', 'stop8' ) ON CONFLICT ( rule_item_id, department_id, scene ) 
                DO UPDATE
                SET operation = excluded.operation

but change to the following sql works perfectly:

INSERT INTO re_rule_mapping ( id, created_time, last_modified_time, rule_item_id, department_id, scene, operation )
                VALUES
                    ( '1', now( ), now( ), '1', '11', 'test', 'stop7' ),
                    ( '2', now( ), now( ), '2', '22', 'test2', 'stop8' ) ON CONFLICT ON CONSTRAINT uk_re_rule_mapping
                DO UPDATE
                SET operation = excluded.operation

Note: [rule_item_id, department_id, scene] is a unique constraint named 'uk_re_rule_mapping' in my db table

Software Information:

  • JSqlParser version 4.6
  • Database (PostgreSQL15)

Tips:

Errors:

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

Was expecting:

    ")"


	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:263)

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