Visitar URL original
[BUG] JSQLParser Version 4.6 : PostgreSQL : Encountered unexpected token: "," "," when parse upsert sql · Issue #1749 · JSQLParser/JSqlParser · GitHub
Skip to content

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

Description

@coldsmirk

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)

Activity

  1. manticore-projects commented on Mar 17, 2023

    @manticore-projects
    Contributor

    Greetings.

    ON CONFLICT ( rule_item_id, department_id, scene ) is not supported for multiple columns.

    Duplicate #1633

  2. coldsmirk commented on Mar 17, 2023

    @coldsmirk
    Author

    Greetings.

    ON CONFLICT ( rule_item_id, department_id, scene ) is not supported for multiple columns.

    Duplicate #1633

    Ok, thanks

  3. added a commit that references this issue on Mar 18, 2023
    043b71a
  4. added a commit that references this issue on Mar 21, 2023
    31ef1aa
  5. added a commit that references this issue on Apr 27, 2023
    a312dcd
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