48 lines
792 B
SQL
48 lines
792 B
SQL
# name: test/sql/upsert/upsert_default.test
|
|
# group: [upsert]
|
|
|
|
statement ok
|
|
pragma enable_verification;
|
|
|
|
statement ok
|
|
create table tbl (
|
|
a integer DEFAULT 5,
|
|
b integer unique,
|
|
c integer DEFAULT 10
|
|
);
|
|
|
|
statement ok
|
|
insert into tbl(b) VALUES (3), (5), (6);
|
|
|
|
statement ok
|
|
insert into tbl(b) VALUES (7), (3), (4) ON CONFLICT do update set c = 5, a = 10;
|
|
|
|
query III rowsort
|
|
select * from tbl;
|
|
----
|
|
10 3 5
|
|
5 4 10
|
|
5 5 10
|
|
5 6 10
|
|
5 7 10
|
|
|
|
statement ok
|
|
create table t (i int primary key, j int);
|
|
|
|
query I
|
|
insert into t values (1, 1) on conflict do nothing;
|
|
----
|
|
1
|
|
|
|
# 0 updates/insertions were performed
|
|
query I
|
|
insert into t values (1, 1) on conflict do nothing
|
|
----
|
|
0
|
|
|
|
# 0 insertions, but one tuple is updated
|
|
query I
|
|
insert into t values (1, 1) on conflict (i) do update set j = excluded.i;
|
|
----
|
|
1
|