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
271 changes: 6 additions & 265 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ toml = "0.5.9"
dir-test = "0.4"
drop_bomb = "0.1.5"
camino = "1.1.9"
pg_query = "6.1.0"
rowan = "0.15.15"
salsa = "0.26.0"
smol_str = "0.3.2"
Expand Down
1 change: 0 additions & 1 deletion crates/squawk_parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ drop_bomb.workspace = true
insta.workspace = true
dir-test.workspace = true
camino.workspace = true
pg_query.workspace = true
xshell.workspace = true
annotate-snippets.workspace = true

Expand Down
7 changes: 7 additions & 0 deletions crates/squawk_parser/tests/data/ok/alter_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,10 @@ alter table t detach partition f finalize;
alter table foo
add constraint foo_bar_id_fkey foreign key (bar_id)
references bar (id) on update cascade on delete cascade;


alter table t alter c set expression as ( a > b );

alter table t set access method default;

alter table t add foreign key (a, b) references t1 match partial;
6 changes: 0 additions & 6 deletions crates/squawk_parser/tests/data/ok/alter_table_pg17.sql

This file was deleted.

16 changes: 16 additions & 0 deletions crates/squawk_parser/tests/data/ok/create_foreign_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,19 @@ create foreign table cal.event_types (
options (
object 'event-types'
);

-- like clause is >=pg18
create foreign table u (
like t
) server s;

-- like clause is >=pg18
create foreign table remote_users (
like local_users
including defaults
including constraints
excluding generated
excluding statistics
excluding all
) server remote_server;

15 changes: 0 additions & 15 deletions crates/squawk_parser/tests/data/ok/create_foreign_table_pg18.sql

This file was deleted.

43 changes: 43 additions & 0 deletions crates/squawk_parser/tests/data/ok/create_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,46 @@ create table t (
create table operator (
x int
);

-- match partial not implemented yet
create table t (
a int,
b int references foo.bar ( bar ) match partial
on delete no action
on update set null ( a, b )
);


-- temporal_foreign_key
CREATE TABLE orders (
id int8 generated BY DEFAULT AS IDENTITY,
address_id int8 NOT NULL,
address_valid_at tstzrange NOT NULL,
content text,
CONSTRAINT order_address FOREIGN KEY ( address_id, PERIOD address_valid_at ) REFERENCES addresses ( id, PERIOD valid_range )
);

-- unique_constraint_without_overlaps
create table t (
a int,
b text,
unique (a without overlaps)
);


-- primary key without overlaps
create table t (
a text,
b text,
c text,
constraint pk
primary key (a, b, c without overlaps)
);

-- temporal_primary_key
CREATE TABLE addresses (
id int8 generated BY DEFAULT AS IDENTITY,
valid_range tstzrange NOT NULL DEFAULT tstzrange(now(), 'infinity', '[)'),
recipient text NOT NULL,
PRIMARY KEY (id, valid_range WITHOUT OVERLAPS)
);
42 changes: 0 additions & 42 deletions crates/squawk_parser/tests/data/ok/create_table_pg17.sql

This file was deleted.

4 changes: 4 additions & 0 deletions crates/squawk_parser/tests/data/ok/insert.sql
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,7 @@ select * from u join i
on conflict = conflict
on conflict
on constraint temporal_rng_pk do nothing;

-- on conflict do select
INSERT INTO t (a) VALUES (1)
ON CONFLICT (a) DO SELECT FOR UPDATE WHERE a > 0 RETURNING *;
3 changes: 0 additions & 3 deletions crates/squawk_parser/tests/data/ok/insert_pg18.sql

This file was deleted.

162 changes: 162 additions & 0 deletions crates/squawk_parser/tests/data/ok/merge.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,165 @@ merge into t
do nothing
when matched then
do nothing;


-- when_clauses_all
merge into t
using u
on t.id = u.id
when not matched then
do nothing
when matched then
do nothing
when not matched by source then
do nothing;

-- when_clauses_all_with_conditions
merge into t
using u on true
when matched and foo = bar then
do nothing
when not matched by source and bar = foo then
do nothing
when not matched and buzz = bar then
do nothing;

-- returning_all
merge into t
using u
on t.id = u.id
when not matched then
do nothing
when matched then
do nothing
when not matched by source then
do nothing
returning *;

-- returning_many
merge into t
using u
on t.id = u.id
when not matched then
do nothing
when matched then
do nothing
when not matched by source then
do nothing
returning *, u as bar, t b, merge_action(), t.*;

-- merge_insert_simple
merge into t
using u
on t.id = u.id
when not matched then
insert
default values;

-- merge_insert_default
merge into t
using u
on t.id = u.id
when not matched then
insert (a, b, c)
overriding user value
default values;

-- merge_insert_values
merge into t
using u
on t.id = u.id
when not matched then
insert
overriding system value
values (1, 2, default, 3, 10 * 10 + 2);

-- merge_update
merge into t
using u
on t.id = u.id
when matched then
update set
a = default,
b = 1,
c = d,
e = (select 1),
f = row(1, 2, default),
g = (1, 2, default),
h = (default)
when not matched by source then
update set foo = bar;

-- merge_delete
merge into t
using u
on t.id = u.id
when matched then
delete
when not matched by source then
delete;

-- with_select
with t as (select 1, 2, 3)
merge into u
using t
on t.id = u.id
when matched then
do nothing;

-- doc_example_1
MERGE INTO customer_account ca
USING recent_transactions t
ON t.customer_id = ca.customer_id
WHEN MATCHED THEN
UPDATE SET balance = balance + transaction_value
WHEN NOT MATCHED THEN
INSERT (customer_id, balance)
VALUES (t.customer_id, t.transaction_value);

-- doc_example_2
MERGE INTO customer_account ca
USING (SELECT customer_id, transaction_value FROM recent_transactions) AS t
ON t.customer_id = ca.customer_id
WHEN MATCHED THEN
UPDATE SET balance = balance + transaction_value
WHEN NOT MATCHED THEN
INSERT (customer_id, balance)
VALUES (t.customer_id, t.transaction_value);

-- doc_example_3
MERGE INTO wines w
USING wine_stock_changes s
ON s.winename = w.winename
WHEN NOT MATCHED AND s.stock_delta > 0 THEN
INSERT VALUES(s.winename, s.stock_delta)
WHEN MATCHED AND w.stock + s.stock_delta > 0 THEN
UPDATE SET stock = w.stock + s.stock_delta
WHEN MATCHED THEN
DELETE
RETURNING merge_action(), w.*;

-- doc_example_4
MERGE INTO wines w
USING new_wine_list s
ON s.winename = w.winename
WHEN NOT MATCHED BY TARGET THEN
INSERT VALUES(s.winename, s.stock)
WHEN MATCHED AND w.stock != s.stock THEN
UPDATE SET stock = s.stock
WHEN NOT MATCHED BY SOURCE THEN
DELETE;

-- cross_join_data_source
merge into t
using u cross join v
on t.id = u.id
when matched then
do nothing;

-- natural join
merge into t
using u natural join v
on t.id = u.id
when matched then
do nothing;
Loading
Loading