should be it
This commit is contained in:
56
external/duckdb/test/sql/upsert/upsert_set_expressions.test
vendored
Normal file
56
external/duckdb/test/sql/upsert/upsert_set_expressions.test
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
# name: test/sql/upsert/upsert_set_expressions.test
|
||||
# group: [upsert]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification;
|
||||
|
||||
# Create a table with only 1 non-indexed column
|
||||
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);
|
||||
|
||||
# the 'i' column is indexed on and 3 already exists, causes a conflict
|
||||
# this updates 'k' to 5
|
||||
statement ok
|
||||
insert into tbl VALUES (3,5,1) ON CONFLICT (i) DO UPDATE SET k = 5;
|
||||
|
||||
query III
|
||||
select * from tbl;
|
||||
----
|
||||
1 10 1
|
||||
2 20 1
|
||||
3 30 5
|
||||
|
||||
# the 'i' column is indexed on and 3 already exists, causes a conflict
|
||||
# this updates 'k' to 1 + excluded.k
|
||||
statement ok
|
||||
insert into tbl VALUES (3,5,1) ON CONFLICT (i) DO UPDATE SET k = 1 + excluded.k;
|
||||
|
||||
query III
|
||||
select * from tbl;
|
||||
----
|
||||
1 10 1
|
||||
2 20 1
|
||||
3 30 2
|
||||
|
||||
# the 'i' column is indexed on and 3 already exists, causes a conflict
|
||||
# this updates 'k' to k + excluded.k
|
||||
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
|
||||
Reference in New Issue
Block a user