darold / pgFormatter

A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI. On-line demo site at http://sqlformat.darold.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Complex formatting problem

ptman opened this issue · comments

Let's call this an INSELECT (instead of UPSERT):

WITH i AS (
INSERT INTO users (email)
        VALUES ($1)
    ON CONFLICT
        DO NOTHING
    RETURNING
        *)
    SELECT
        *
    FROM
        i
    UNION
    SELECT
        *
    FROM
        users
    WHERE
        email = $1