38 lines
644 B
SQL
38 lines
644 B
SQL
# name: test/sql/upsert/upsert_unique_null.test
|
|
# group: [upsert]
|
|
|
|
statement ok
|
|
pragma enable_verification;
|
|
|
|
statement ok
|
|
create or replace table tbl (
|
|
a integer unique,
|
|
b integer
|
|
);
|
|
|
|
statement ok
|
|
insert into tbl VALUES (3,2), (1,3);
|
|
|
|
statement ok
|
|
insert into tbl(b) VALUES (5) ON CONFLICT (a) DO UPDATE SET b = 8;
|
|
|
|
# UNIQUE can be NULL, PRIMARY KEY can't be
|
|
query II
|
|
select * from tbl;
|
|
----
|
|
3 2
|
|
1 3
|
|
NULL 5
|
|
|
|
statement ok
|
|
insert into tbl(b) VALUES (5) ON CONFLICT (a) DO UPDATE SET b = 8;
|
|
|
|
# And NULL does not take part in the UNIQUE Index, so it does not activate the ON CONFLICT clause
|
|
query II
|
|
select * from tbl;
|
|
----
|
|
3 2
|
|
1 3
|
|
NULL 5
|
|
NULL 5
|