35 lines
570 B
SQL
35 lines
570 B
SQL
# name: test/sql/upsert/minimal_reproducable_example.test
|
|
# group: [upsert]
|
|
|
|
statement ok
|
|
pragma enable_verification;
|
|
|
|
# Create a table with 3 columns, 2 of which are indexed on
|
|
statement ok
|
|
create or replace table tbl(
|
|
i integer PRIMARY KEY,
|
|
j integer UNIQUE,
|
|
k integer
|
|
);
|
|
|
|
# Add 3 rows
|
|
statement ok
|
|
insert into tbl VALUES (1, 10, 1), (2, 20, 1), (3, 30, 2);
|
|
|
|
query III
|
|
select * from tbl;
|
|
----
|
|
1 10 1
|
|
2 20 1
|
|
3 30 2
|
|
|
|
statement ok
|
|
insert into tbl VALUES (3,5,1) ON CONFLICT (i) DO UPDATE SET k = k + excluded.k;
|
|
|
|
query III
|
|
select * from tbl;
|
|
----
|
|
1 10 1
|
|
2 20 1
|
|
3 30 3
|