Files
email-tracker/external/duckdb/test/sql/upsert/upsert_default_expressions.test
2025-10-24 19:21:19 -05:00

43 lines
887 B
SQL

# name: test/sql/upsert/upsert_default_expressions.test
# group: [upsert]
statement ok
pragma enable_verification;
statement ok
create or replace table tbl (
a integer primary key default 4,
b integer DEFAULT 3
);
statement ok
insert into tbl VALUES (2,3), (4,5)
query II
select * from tbl;
----
2 3
4 5
# DEFAULT in set expression
statement ok
insert into tbl VALUES (DEFAULT, 6) ON CONFLICT (a) DO UPDATE SET b = DEFAULT
query II
select * from tbl;
----
2 3
4 3
# DEFAULT in ON CONFLICT (..) WHERE <expr>
statement error
insert into tbl VALUES (4,8) ON CONFLICT (a) DO UPDATE SET b = excluded.b WHERE a = DEFAULT;
----
WHERE clause cannot contain DEFAULT clause
# DEFAULT in DO UPDATE SET .. WHERE <expr>
statement error
insert into tbl VALUES (4,3) ON CONFLICT (a) DO UPDATE SET b = excluded.b WHERE excluded.b = DEFAULT * 2;
----
WHERE clause cannot contain DEFAULT clause