Skip to content

Commit c5186ac

Browse files
committed
pretty
1 parent bb72dce commit c5186ac

18 files changed

+368
-393
lines changed

__fixtures__/generated/generated.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@
3030
"pretty/misc-14.sql": "CREATE TRIGGER decrease_job_queue_count_on_delete \n AFTER DELETE ON dashboard_jobs.jobs \n FOR EACH ROW\n WHEN ( OLD.queue_name IS NOT NULL ) \n EXECUTE PROCEDURE dashboard_jobs.tg_decrease_job_queue_count ()",
3131
"pretty/misc-15.sql": "ALTER DEFAULT PRIVILEGES IN SCHEMA dashboard_jobs \n GRANT EXECUTE ON FUNCTIONS TO administrator",
3232
"pretty/misc-16.sql": "GRANT EXECUTE ON FUNCTION dashboard_private.uuid_generate_seeded_uuid TO PUBLIC",
33+
"pretty/cte-1.sql": "WITH regional_sales AS (SELECT region, SUM(sales_amount) as total_sales FROM sales GROUP BY region) SELECT * FROM regional_sales",
34+
"pretty/cte-2.sql": "WITH regional_sales AS (SELECT region, SUM(sales_amount) as total_sales FROM sales GROUP BY region), top_regions AS (SELECT region FROM regional_sales WHERE total_sales > 1000000) SELECT * FROM top_regions",
35+
"pretty/cte-3.sql": "WITH RECURSIVE employee_hierarchy AS (SELECT id, name, manager_id, 1 as level FROM employees WHERE manager_id IS NULL UNION ALL SELECT e.id, e.name, e.manager_id, eh.level + 1 FROM employees e JOIN employee_hierarchy eh ON e.manager_id = eh.id) SELECT * FROM employee_hierarchy",
36+
"pretty/cte-4.sql": "WITH sales_summary AS (SELECT region, product_category, SUM(amount) as total FROM sales GROUP BY region, product_category), regional_totals AS (SELECT region, SUM(total) as region_total FROM sales_summary GROUP BY region) SELECT s.region, s.product_category, s.total, r.region_total FROM sales_summary s JOIN regional_totals r ON s.region = r.region",
3337
"pretty/create_table-1.sql": "CREATE TABLE users (\n id SERIAL PRIMARY KEY,\n name TEXT NOT NULL,\n email TEXT UNIQUE\n)",
3438
"pretty/create_table-2.sql": "CREATE TABLE products (\n id SERIAL PRIMARY KEY,\n name VARCHAR(255) NOT NULL,\n price DECIMAL(10,2) CHECK (price > 0),\n category_id INTEGER,\n description TEXT,\n created_at TIMESTAMP DEFAULT now(),\n updated_at TIMESTAMP,\n UNIQUE (name, category_id),\n FOREIGN KEY (category_id) REFERENCES categories(id)\n)",
3539
"pretty/create_table-3.sql": "CREATE TABLE orders (\n id SERIAL PRIMARY KEY,\n subtotal DECIMAL(10,2) NOT NULL,\n tax_rate DECIMAL(5,4) DEFAULT 0.0825,\n tax_amount DECIMAL(10,2) GENERATED ALWAYS AS (subtotal * tax_rate) STORED,\n total DECIMAL(10,2) GENERATED ALWAYS AS (subtotal + tax_amount) STORED\n)",
3640
"pretty/create_table-4.sql": "CREATE TABLE sales (\n id SERIAL,\n sale_date DATE NOT NULL,\n amount DECIMAL(10,2),\n region VARCHAR(50)\n) PARTITION BY RANGE (sale_date)",
3741
"pretty/create_table-5.sql": "CREATE TEMPORARY TABLE temp_calculations (\n id INTEGER,\n value DECIMAL(15,5),\n result TEXT\n)",
42+
"pretty/create_table-6.sql": "CREATE TABLE orders (\n id SERIAL PRIMARY KEY,\n user_id INTEGER NOT NULL,\n total DECIMAL(10,2) CHECK (total > 0),\n status VARCHAR(20) DEFAULT 'pending',\n created_at TIMESTAMP DEFAULT now(),\n FOREIGN KEY (user_id) REFERENCES users(id)\n)",
3843
"pretty/create_policy-1.sql": "CREATE POLICY user_policy ON users FOR ALL TO authenticated_users USING (user_id = current_user_id())",
3944
"pretty/create_policy-2.sql": "CREATE POLICY admin_policy ON sensitive_data \n AS RESTRICTIVE \n FOR SELECT \n TO admin_role \n USING (department = current_user_department()) \n WITH CHECK (approved = true)",
4045
"pretty/create_policy-3.sql": "CREATE POLICY complex_policy ON documents \n FOR UPDATE \n TO document_editors \n USING (\n owner_id = current_user_id() OR \n (shared = true AND permissions @> '{\"edit\": true}')\n ) \n WITH CHECK (\n status != 'archived' AND \n last_modified > now() - interval '1 day'\n )",

__fixtures__/kitchen-sink/pretty/create_table.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ CREATE TEMPORARY TABLE temp_calculations (
3737
value DECIMAL(15,5),
3838
result TEXT
3939
);
40+
41+
CREATE TABLE orders (
42+
id SERIAL PRIMARY KEY,
43+
user_id INTEGER NOT NULL,
44+
total DECIMAL(10,2) CHECK (total > 0),
45+
status VARCHAR(20) DEFAULT 'pending',
46+
created_at TIMESTAMP DEFAULT now(),
47+
FOREIGN KEY (user_id) REFERENCES users(id)
48+
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
WITH regional_sales AS (SELECT region, SUM(sales_amount) as total_sales FROM sales GROUP BY region) SELECT * FROM regional_sales;
2+
3+
WITH regional_sales AS (SELECT region, SUM(sales_amount) as total_sales FROM sales GROUP BY region), top_regions AS (SELECT region FROM regional_sales WHERE total_sales > 1000000) SELECT * FROM top_regions;
4+
5+
WITH RECURSIVE employee_hierarchy AS (SELECT id, name, manager_id, 1 as level FROM employees WHERE manager_id IS NULL UNION ALL SELECT e.id, e.name, e.manager_id, eh.level + 1 FROM employees e JOIN employee_hierarchy eh ON e.manager_id = eh.id) SELECT * FROM employee_hierarchy;
6+
7+
WITH sales_summary AS (SELECT region, product_category, SUM(amount) as total FROM sales GROUP BY region, product_category), regional_totals AS (SELECT region, SUM(total) as region_total FROM sales_summary GROUP BY region) SELECT s.region, s.product_category, s.total, r.region_total FROM sales_summary s JOIN regional_totals r ON s.region = r.region;

packages/deparser/__tests__/kitchen-sink/pretty-create_table.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ it('pretty-create_table', async () => {
88
"pretty/create_table-2.sql",
99
"pretty/create_table-3.sql",
1010
"pretty/create_table-4.sql",
11-
"pretty/create_table-5.sql"
11+
"pretty/create_table-5.sql",
12+
"pretty/create_table-6.sql"
1213
]);
1314
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import { FixtureTestUtils } from '../../test-utils';
3+
const fixtures = new FixtureTestUtils();
4+
5+
it('pretty-cte', async () => {
6+
await fixtures.runFixtureTests([
7+
"pretty/cte-1.sql",
8+
"pretty/cte-2.sql",
9+
"pretty/cte-3.sql",
10+
"pretty/cte-4.sql"
11+
]);
12+
});
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Pretty constraint formatting should format check constraint with pretty option enabled 1`] = `"ALTER TABLE products ADD CONSTRAINT check_price CHECK (price > 0);"`;
3+
exports[`should format constraints-1: pretty/constraints-1.sql (non-pretty) 1`] = `"CREATE TABLE orders (id serial PRIMARY KEY, user_id int NOT NULL, total numeric(10, 2) CHECK (total > 0), status varchar(20) DEFAULT 'pending', created_at pg_catalog.timestamp DEFAULT now(), CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE, CONSTRAINT unique_user_date UNIQUE (user_id, created_at), CONSTRAINT check_status CHECK (status IN ('pending', 'completed', 'cancelled')))"`;
44

5-
exports[`Pretty constraint formatting should format complex table with constraints with pretty option enabled 1`] = `
5+
exports[`should format constraints-1: pretty/constraints-1.sql (pretty) 1`] = `
66
"CREATE TABLE orders (
77
id serial PRIMARY KEY,
88
user_id int NOT NULL,
99
total numeric(10, 2) CHECK (total > 0),
1010
status varchar(20) DEFAULT 'pending',
11+
created_at pg_catalog.timestamp DEFAULT now(),
1112
CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES users (id)
12-
ON DELETE CASCADE
13-
);"
13+
ON DELETE CASCADE,
14+
CONSTRAINT unique_user_date UNIQUE (user_id, created_at),
15+
CONSTRAINT check_status CHECK (status IN ('pending', 'completed', 'cancelled'))
16+
)"
1417
`;
1518

16-
exports[`Pretty constraint formatting should format foreign key constraint with pretty option enabled 1`] = `
19+
exports[`should format constraints-2: pretty/constraints-2.sql (non-pretty) 1`] = `"ALTER TABLE products ADD CONSTRAINT fk_category FOREIGN KEY (category_id) REFERENCES categories (id) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED"`;
20+
21+
exports[`should format constraints-2: pretty/constraints-2.sql (pretty) 1`] = `
1722
"ALTER TABLE products ADD CONSTRAINT fk_category FOREIGN KEY (category_id) REFERENCES categories (id)
1823
ON UPDATE CASCADE
1924
ON DELETE SET NULL
2025
DEFERRABLE
21-
INITIALLY DEFERRED;"
26+
INITIALLY DEFERRED"
2227
`;
2328

24-
exports[`Pretty constraint formatting should maintain single-line format for complex table when pretty disabled 1`] = `"CREATE TABLE orders (id serial PRIMARY KEY, user_id int NOT NULL, total numeric(10, 2) CHECK (total > 0), status varchar(20) DEFAULT 'pending', CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE);"`;
29+
exports[`should format constraints-3: pretty/constraints-3.sql (non-pretty) 1`] = `"ALTER TABLE products ADD CONSTRAINT check_price CHECK (price > 0)"`;
2530

26-
exports[`Pretty constraint formatting should maintain single-line format when pretty option disabled 1`] = `"ALTER TABLE products ADD CONSTRAINT fk_category FOREIGN KEY (category_id) REFERENCES categories (id) ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;"`;
31+
exports[`should format constraints-3: pretty/constraints-3.sql (pretty) 1`] = `"ALTER TABLE products ADD CONSTRAINT check_price CHECK (price > 0)"`;
2732

28-
exports[`Pretty constraint formatting should use custom newline and tab characters in pretty mode 1`] = `
29-
"ALTER TABLE products ADD CONSTRAINT fk_category FOREIGN KEY (category_id) REFERENCES categories (id)
30-
ON UPDATE CASCADE
31-
ON DELETE SET NULL
32-
DEFERRABLE
33-
INITIALLY DEFERRED;"
34-
`;
33+
exports[`should format constraints-4: pretty/constraints-4.sql (non-pretty) 1`] = `"ALTER TABLE users ADD CONSTRAINT unique_email UNIQUE (email)"`;
34+
35+
exports[`should format constraints-4: pretty/constraints-4.sql (pretty) 1`] = `"ALTER TABLE users ADD CONSTRAINT unique_email UNIQUE (email)"`;

packages/deparser/__tests__/pretty/__snapshots__/create-policy-pretty.test.ts.snap

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-1.sql: (non-pretty) 1`] = `"CREATE POLICY "user_policy" ON users AS PERMISSIVE FOR ALL TO authenticated_users USING (user_id = current_user_id())"`;
3+
exports[`should format create_policy-1: pretty/create_policy-1.sql (non-pretty) 1`] = `"CREATE POLICY "user_policy" ON users AS PERMISSIVE FOR ALL TO authenticated_users USING (user_id = current_user_id())"`;
44

5-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-1.sql: (pretty) 1`] = `
5+
exports[`should format create_policy-1: pretty/create_policy-1.sql (pretty) 1`] = `
66
"CREATE POLICY "user_policy"
77
ON users
88
AS PERMISSIVE
@@ -13,9 +13,9 @@ exports[`Pretty Misc SQL formatting should format pretty/create_policy-1.sql: (p
1313
)"
1414
`;
1515

16-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-2.sql: (non-pretty) 1`] = `"CREATE POLICY "admin_policy" ON sensitive_data AS RESTRICTIVE FOR SELECT TO admin_role USING (department = current_user_department()) WITH CHECK (approved = true)"`;
16+
exports[`should format create_policy-2: pretty/create_policy-2.sql (non-pretty) 1`] = `"CREATE POLICY "admin_policy" ON sensitive_data AS RESTRICTIVE FOR SELECT TO admin_role USING (department = current_user_department()) WITH CHECK (approved = true)"`;
1717

18-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-2.sql: (pretty) 1`] = `
18+
exports[`should format create_policy-2: pretty/create_policy-2.sql (pretty) 1`] = `
1919
"CREATE POLICY "admin_policy"
2020
ON sensitive_data
2121
AS RESTRICTIVE
@@ -29,9 +29,9 @@ exports[`Pretty Misc SQL formatting should format pretty/create_policy-2.sql: (p
2929
)"
3030
`;
3131

32-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-3.sql: (non-pretty) 1`] = `"CREATE POLICY "complex_policy" ON documents AS PERMISSIVE FOR UPDATE TO document_editors USING (owner_id = current_user_id() OR (shared = true AND permissions @> '{"edit": true}')) WITH CHECK (status <> 'archived' AND last_modified > (now() - '1 day'::interval))"`;
32+
exports[`should format create_policy-3: pretty/create_policy-3.sql (non-pretty) 1`] = `"CREATE POLICY "complex_policy" ON documents AS PERMISSIVE FOR UPDATE TO document_editors USING (owner_id = current_user_id() OR (shared = true AND permissions @> '{"edit": true}')) WITH CHECK (status <> 'archived' AND last_modified > (now() - '1 day'::interval))"`;
3333

34-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-3.sql: (pretty) 1`] = `
34+
exports[`should format create_policy-3: pretty/create_policy-3.sql (pretty) 1`] = `
3535
"CREATE POLICY "complex_policy"
3636
ON documents
3737
AS PERMISSIVE
@@ -48,9 +48,9 @@ exports[`Pretty Misc SQL formatting should format pretty/create_policy-3.sql: (p
4848
)"
4949
`;
5050

51-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-4.sql: (non-pretty) 1`] = `"CREATE POLICY "simple_policy" ON posts AS PERMISSIVE FOR SELECT TO PUBLIC USING (published = true)"`;
51+
exports[`should format create_policy-4: pretty/create_policy-4.sql (non-pretty) 1`] = `"CREATE POLICY "simple_policy" ON posts AS PERMISSIVE FOR SELECT TO PUBLIC USING (published = true)"`;
5252

53-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-4.sql: (pretty) 1`] = `
53+
exports[`should format create_policy-4: pretty/create_policy-4.sql (pretty) 1`] = `
5454
"CREATE POLICY "simple_policy"
5555
ON posts
5656
AS PERMISSIVE
@@ -61,9 +61,9 @@ exports[`Pretty Misc SQL formatting should format pretty/create_policy-4.sql: (p
6161
)"
6262
`;
6363

64-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-5.sql: (non-pretty) 1`] = `"CREATE POLICY "simple_policy" ON posts AS PERMISSIVE FOR SELECT TO PUBLIC USING (published = true)"`;
64+
exports[`should format create_policy-5: pretty/create_policy-5.sql (non-pretty) 1`] = `"CREATE POLICY "simple_policy" ON posts AS PERMISSIVE FOR SELECT TO PUBLIC USING (published = true)"`;
6565

66-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-5.sql: (pretty) 1`] = `
66+
exports[`should format create_policy-5: pretty/create_policy-5.sql (pretty) 1`] = `
6767
"CREATE POLICY "simple_policy"
6868
ON posts
6969
AS PERMISSIVE
@@ -74,9 +74,9 @@ exports[`Pretty Misc SQL formatting should format pretty/create_policy-5.sql: (p
7474
)"
7575
`;
7676

77-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-6.sql: (non-pretty) 1`] = `"CREATE POLICY "Simple Policy" ON posts AS PERMISSIVE FOR SELECT TO PUBLIC USING (published = true)"`;
77+
exports[`should format create_policy-6: pretty/create_policy-6.sql (non-pretty) 1`] = `"CREATE POLICY "Simple Policy" ON posts AS PERMISSIVE FOR SELECT TO PUBLIC USING (published = true)"`;
7878

79-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-6.sql: (pretty) 1`] = `
79+
exports[`should format create_policy-6: pretty/create_policy-6.sql (pretty) 1`] = `
8080
"CREATE POLICY "Simple Policy"
8181
ON posts
8282
AS PERMISSIVE
@@ -87,9 +87,9 @@ exports[`Pretty Misc SQL formatting should format pretty/create_policy-6.sql: (p
8787
)"
8888
`;
8989

90-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-7.sql: (non-pretty) 1`] = `"CREATE POLICY "simplepolicy" ON posts AS PERMISSIVE FOR SELECT TO PUBLIC USING (published = true)"`;
90+
exports[`should format create_policy-7: pretty/create_policy-7.sql (non-pretty) 1`] = `"CREATE POLICY "simplepolicy" ON posts AS PERMISSIVE FOR SELECT TO PUBLIC USING (published = true)"`;
9191

92-
exports[`Pretty Misc SQL formatting should format pretty/create_policy-7.sql: (pretty) 1`] = `
92+
exports[`should format create_policy-7: pretty/create_policy-7.sql (pretty) 1`] = `
9393
"CREATE POLICY "simplepolicy"
9494
ON posts
9595
AS PERMISSIVE
Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,73 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Pretty CREATE TABLE formatting should format basic CREATE TABLE with pretty option enabled 1`] = `
3+
exports[`should format create_table-1: pretty/create_table-1.sql (non-pretty) 1`] = `"CREATE TABLE users (id serial PRIMARY KEY, name text NOT NULL, email text UNIQUE)"`;
4+
5+
exports[`should format create_table-1: pretty/create_table-1.sql (pretty) 1`] = `
46
"CREATE TABLE users (
57
id serial PRIMARY KEY,
68
name text NOT NULL,
79
email text UNIQUE
8-
);"
10+
)"
11+
`;
12+
13+
exports[`should format create_table-2: pretty/create_table-2.sql (non-pretty) 1`] = `"CREATE TABLE products (id serial PRIMARY KEY, name varchar(255) NOT NULL, price numeric(10, 2) CHECK (price > 0), category_id int, description text, created_at pg_catalog.timestamp DEFAULT now(), updated_at pg_catalog.timestamp, UNIQUE (name, category_id), FOREIGN KEY (category_id) REFERENCES categories (id))"`;
14+
15+
exports[`should format create_table-2: pretty/create_table-2.sql (pretty) 1`] = `
16+
"CREATE TABLE products (
17+
id serial PRIMARY KEY,
18+
name varchar(255) NOT NULL,
19+
price numeric(10, 2) CHECK (price > 0),
20+
category_id int,
21+
description text,
22+
created_at pg_catalog.timestamp DEFAULT now(),
23+
updated_at pg_catalog.timestamp,
24+
UNIQUE (name, category_id),
25+
FOREIGN KEY (category_id) REFERENCES categories (id)
26+
)"
927
`;
1028

11-
exports[`Pretty CREATE TABLE formatting should format complex CREATE TABLE with pretty option enabled 1`] = `
29+
exports[`should format create_table-3: pretty/create_table-3.sql (non-pretty) 1`] = `"CREATE TABLE orders (id serial PRIMARY KEY, subtotal numeric(10, 2) NOT NULL, tax_rate numeric(5, 4) DEFAULT 0.0825, tax_amount numeric(10, 2) GENERATED ALWAYS AS (subtotal * tax_rate) STORED, total numeric(10, 2) GENERATED ALWAYS AS (subtotal + tax_amount) STORED)"`;
30+
31+
exports[`should format create_table-3: pretty/create_table-3.sql (pretty) 1`] = `
32+
"CREATE TABLE orders (
33+
id serial PRIMARY KEY,
34+
subtotal numeric(10, 2) NOT NULL,
35+
tax_rate numeric(5, 4) DEFAULT 0.0825,
36+
tax_amount numeric(10, 2) GENERATED ALWAYS AS (subtotal * tax_rate) STORED,
37+
total numeric(10, 2) GENERATED ALWAYS AS (subtotal + tax_amount) STORED
38+
)"
39+
`;
40+
41+
exports[`should format create_table-4: pretty/create_table-4.sql (non-pretty) 1`] = `"CREATE TABLE sales (id serial, sale_date date NOT NULL, amount numeric(10, 2), region varchar(50)) PARTITION BY RANGE (sale_date)"`;
42+
43+
exports[`should format create_table-4: pretty/create_table-4.sql (pretty) 1`] = `
44+
"CREATE TABLE sales (
45+
id serial,
46+
sale_date date NOT NULL,
47+
amount numeric(10, 2),
48+
region varchar(50)
49+
) PARTITION BY RANGE (sale_date)"
50+
`;
51+
52+
exports[`should format create_table-5: pretty/create_table-5.sql (non-pretty) 1`] = `"CREATE TEMPORARY TABLE temp_calculations (id int, value numeric(15, 5), result text)"`;
53+
54+
exports[`should format create_table-5: pretty/create_table-5.sql (pretty) 1`] = `
55+
"CREATE TEMPORARY TABLE temp_calculations (
56+
id int,
57+
value numeric(15, 5),
58+
result text
59+
)"
60+
`;
61+
62+
exports[`should format create_table-6: pretty/create_table-6.sql (non-pretty) 1`] = `"CREATE TABLE orders (id serial PRIMARY KEY, user_id int NOT NULL, total numeric(10, 2) CHECK (total > 0), status varchar(20) DEFAULT 'pending', created_at pg_catalog.timestamp DEFAULT now(), FOREIGN KEY (user_id) REFERENCES users (id))"`;
63+
64+
exports[`should format create_table-6: pretty/create_table-6.sql (pretty) 1`] = `
1265
"CREATE TABLE orders (
1366
id serial PRIMARY KEY,
1467
user_id int NOT NULL,
1568
total numeric(10, 2) CHECK (total > 0),
1669
status varchar(20) DEFAULT 'pending',
1770
created_at pg_catalog.timestamp DEFAULT now(),
1871
FOREIGN KEY (user_id) REFERENCES users (id)
19-
);"
20-
`;
21-
22-
exports[`Pretty CREATE TABLE formatting should maintain single-line format for complex table when pretty disabled 1`] = `"CREATE TABLE orders (id serial PRIMARY KEY, user_id int NOT NULL, total numeric(10, 2) CHECK (total > 0), status varchar(20) DEFAULT 'pending', created_at pg_catalog.timestamp DEFAULT now(), FOREIGN KEY (user_id) REFERENCES users (id));"`;
23-
24-
exports[`Pretty CREATE TABLE formatting should maintain single-line format when pretty option disabled 1`] = `"CREATE TABLE users (id serial PRIMARY KEY, name text NOT NULL, email text UNIQUE);"`;
25-
26-
exports[`Pretty CREATE TABLE formatting should use custom newline and tab characters in pretty mode 1`] = `
27-
"CREATE TABLE users (
28-
id serial PRIMARY KEY,
29-
name text NOT NULL,
30-
email text UNIQUE
31-
);"
72+
)"
3273
`;

0 commit comments

Comments
 (0)