PostgreSQL Formatting Guide
Master PostgreSQL SQL code formatting methods
PostgreSQL-Specific Syntax Support
PostgreSQL has rich extended syntax, and our formatter correctly handles:
- RETURNING clause
- ARRAY type constructor
- JSON/JSONB operators
- CTE (WITH clause)
- Window functions
- LATERAL JOIN
Formatting Example
Before formatting:
WITH monthly_sales AS (SELECT DATE_TRUNC('month',created_at) as month,SUM(total) as total FROM orders GROUP BY month) SELECT month,total FROM monthly_sales ORDER BY month DESC;After formatting:
WITH monthly_sales AS (
SELECT
DATE_TRUNC('month', created_at) AS month,
SUM(total) AS total
FROM orders
GROUP BY
month
)
SELECT
month,
total
FROM monthly_sales
ORDER BY month DESC;