Open
Description
Input data
SELECT set.foo FROM settings AS set
Here's a more complex example (the error is a bit different):
SELECT id AS srvid,
CASE WHEN id = $1 THEN $2
ELSE
COALESCE(alias, hostname || $3 || port)
END AS alias,
CASE WHEN id = $4 THEN $5 ELSE hostname END as hostname,
CASE WHEN id = $6 THEN $7 ELSE port END AS port,
CASE WHEN id = $8 THEN set.setting
ELSE s.version::text
END AS version
FROM public.powa_servers s
LEFT JOIN pg_settings set ON set.name = $9 AND s.id = $10
Usage
- How are you calling / using the library?
import { formatDialect, postgresql } from "sql-formatter";
formatDialect(value, { dialect: postgresql })
Tested in the online demo as well.
-
What SQL language(s) does this apply to?
PostgreSQL, but the first example fails with any dialect with the same error -
Which SQL Formatter version are you using?
15.4.6