should be it

This commit is contained in:
2025-10-24 19:21:19 -05:00
parent a4b23fc57c
commit f09560c7b1
14047 changed files with 3161551 additions and 1 deletions

View File

@@ -0,0 +1,90 @@
# name: test/sql/constraints/unique/test_unique.test
# description: Single UNIQUE constraint
# group: [unique]
statement ok
SET default_null_order='nulls_first';
statement ok
CREATE TABLE integers(i INTEGER UNIQUE, j INTEGER)
# insert unique values
statement ok
INSERT INTO integers VALUES (3, 4), (2, 5)
query II
SELECT * FROM integers
----
3 4
2 5
# insert a duplicate value as part of a chain of values, this should fail
statement error
INSERT INTO integers VALUES (6, 6), (3, 4);
----
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
# but if we try to replace them like this it's going to fail
statement error
UPDATE integers SET i=77 WHERE i IS NULL
----
query II
SELECT * FROM integers ORDER BY i, j
----
NULL 6
NULL 7
2 5
3 4
# we can replace them like this though
statement ok
UPDATE integers SET i=77 WHERE i IS NULL AND j=6
query II
SELECT * FROM integers ORDER BY i, j
----
NULL 7
2 5
3 4
77 6
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement ok
INSERT INTO integers VALUES (NULL, 6), (NULL, 7)
statement error
INSERT INTO integers VALUES (NULL, 6), (3, 7)
----
statement ok
DROP TABLE integers