Skip to content

INSERT from SELECT cannot be parsed with an ON CONFLICT clause #1987

@rtimush

Description

@rtimush

Parsing the following SQL

INSERT INTO foo
  SELECT 1, 'data'
  ON CONFLICT DO NOTHING

fails with

Expected: end of statement, found: CONFLICT at Line: 3, Column: 6

both for Generic and PostgreSQL dialects.

However, at least in PostgreSQL it seems to be a valid construct, equivalent to

INSERT INTO foo
  (SELECT 1, 'data')
  ON CONFLICT DO NOTHING

(this one is parsed by sqlparser correctly).

The same query without the "ON CONFLICT" clause can be successfully parsed too.

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