Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 290 additions & 2 deletions src/formatter/stmt.rs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tests/fixtures/river/create_table_if_not_exists.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE TABLE IF NOT EXISTS t (
a INTEGER
);
1 change: 1 addition & 0 deletions tests/fixtures/river/create_table_if_not_exists.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE IF NOT EXISTS t (a int)
4 changes: 4 additions & 0 deletions tests/fixtures/river/create_table_inherits.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE t (
a INTEGER
)
INHERITS (parent);
1 change: 1 addition & 0 deletions tests/fixtures/river/create_table_inherits.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE t (a int) INHERITS (parent)
4 changes: 4 additions & 0 deletions tests/fixtures/river/create_table_partition_by.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE t (
a INTEGER
)
PARTITION BY RANGE (a);
1 change: 1 addition & 0 deletions tests/fixtures/river/create_table_partition_by.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE t (a int) PARTITION BY RANGE (a)
4 changes: 4 additions & 0 deletions tests/fixtures/river/create_table_tablespace.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE t (
a INTEGER
)
TABLESPACE ts;
1 change: 1 addition & 0 deletions tests/fixtures/river/create_table_tablespace.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE t (a int) TABLESPACE ts
2 changes: 2 additions & 0 deletions tests/fixtures/river/create_view_or_replace.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE OR REPLACE VIEW v AS
SELECT 1;
1 change: 1 addition & 0 deletions tests/fixtures/river/create_view_or_replace.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE OR REPLACE VIEW v AS SELECT 1
2 changes: 2 additions & 0 deletions tests/fixtures/river/create_view_temp.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE TEMP VIEW v AS
SELECT 1;
1 change: 1 addition & 0 deletions tests/fixtures/river/create_view_temp.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TEMP VIEW v AS SELECT 1
4 changes: 4 additions & 0 deletions tests/fixtures/river/delete_returning.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DELETE
FROM t
WHERE id = 1
RETURNING id;
1 change: 1 addition & 0 deletions tests/fixtures/river/delete_returning.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM t WHERE id = 1 RETURNING id
4 changes: 4 additions & 0 deletions tests/fixtures/river/delete_using.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DELETE
FROM t
USING other AS o
WHERE t.id = o.id;
1 change: 1 addition & 0 deletions tests/fixtures/river/delete_using.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM t USING other o WHERE t.id = o.id
1 change: 1 addition & 0 deletions tests/fixtures/river/insert_default_values.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO t DEFAULT VALUES;
1 change: 1 addition & 0 deletions tests/fixtures/river/insert_default_values.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO t DEFAULT VALUES
3 changes: 3 additions & 0 deletions tests/fixtures/river/insert_on_conflict_do_nothing.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO t (a, b)
VALUES (1, 2)
ON CONFLICT (a) DO NOTHING;
1 change: 1 addition & 0 deletions tests/fixtures/river/insert_on_conflict_do_nothing.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO t (a, b) VALUES (1, 2) ON CONFLICT (a) DO NOTHING
3 changes: 3 additions & 0 deletions tests/fixtures/river/insert_on_conflict_do_update.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO t (a, b)
VALUES (1, 2)
ON CONFLICT (a) DO UPDATE SET b = 2;
1 change: 1 addition & 0 deletions tests/fixtures/river/insert_on_conflict_do_update.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO t (a, b) VALUES (1, 2) ON CONFLICT (a) DO UPDATE SET b = 2
2 changes: 2 additions & 0 deletions tests/fixtures/river/insert_overriding_system.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO t (a) OVERRIDING SYSTEM VALUE
VALUES (1);
1 change: 1 addition & 0 deletions tests/fixtures/river/insert_overriding_system.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO t (a) OVERRIDING SYSTEM VALUE VALUES (1)
3 changes: 3 additions & 0 deletions tests/fixtures/river/insert_returning.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO t (a)
VALUES (1)
RETURNING a;
1 change: 1 addition & 0 deletions tests/fixtures/river/insert_returning.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO t (a) VALUES (1) RETURNING a
4 changes: 4 additions & 0 deletions tests/fixtures/river/update_from.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UPDATE t
SET a = s.a
FROM src AS s
WHERE t.id = s.id;
1 change: 1 addition & 0 deletions tests/fixtures/river/update_from.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE t SET a = s.a FROM src s WHERE t.id = s.id
4 changes: 4 additions & 0 deletions tests/fixtures/river/update_returning.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UPDATE t
SET a = 1
WHERE id = 1
RETURNING a;
1 change: 1 addition & 0 deletions tests/fixtures/river/update_returning.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UPDATE t SET a = 1 WHERE id = 1 RETURNING a