Skip to content

ON CONFLICT DO UPDATE is broken #434

Open
@dkrieger

Description

@dkrieger

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

ON CONFLICT .. DO UPDATE queries are improperly flagged as invalid syntax, and the LSP Is interpreting it as 2 separate statements (2nd starting with "UPDATE"). Putting the same syntax inside a CTE is considered valid by the LSP.

To Reproduce

write this query and observe the squiggles; it's interpreting it as two separate statements, first one ending on DO (inclusive)

INSERT INTO foo.bar (
    pk
) VALUES (
    $1
) ON CONFLICT (pk) DO UPDATE SET
    date_deleted = DEFAULT,
    date_created = DEFAULT;

Now put this same thing inside a CTE and observe that the LSP does not complain

WITH asdf AS (
    INSERT INTO foo.bar (
        pk
    ) VALUES (
        $1
    ) ON CONFLICT (pk) DO UPDATE SET
        date_deleted = DEFAULT,
        date_created = DEFAULT
) SELECT 1;

Expected behavior

Recognize valid syntax when using ON CONFLICT .. DO UPDATE in any context

System information

  • OS: macos

Additional context

  • IDE: vscode w/ postgrestools extension
  • used default/suggested config with the db section removed so that it's all LSP / not using db connection

Add any other context about the problem here.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions