Skip to content

Commit

Permalink
Merge pull request #2812 from szarnyasg/iss2811
Browse files Browse the repository at this point in the history
Duplicate key
  • Loading branch information
szarnyasg authored May 17, 2024
2 parents ba38d34 + 9e60940 commit e7dbd5b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/sql/data_types/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ comparing a `NULL` nested value to a non-`NULL` nested value produces a `NULL` r
Comparing nested value _members_, however, uses the internal nested value rules for `NULL`s,
and a `NULL` nested value member will compare above a non-`NULL` nested value member.

## Updating Lists

Updates on lists are internally represented as an insert and a delete operation.
Therefore, updating list values may lead to a duplicate key error on primary/unique keys.
See the following example:

```sql
CREATE TABLE tbl (id INTEGER PRIMARY KEY, lst INTEGER[], comment VARCHAR);
INSERT INTO tbl VALUES (1, [12, 34], 'asd');
UPDATE tbl SET lst = [56, 78] WHERE id = 1;
```

```console
Constraint Error: Duplicate key "id: 1" violates primary key constraint.
If this is an unexpected constraint violation please double check with the known index limitations section in our documentation (https://duckdb.org/docs/sql/indexes).
```

## Functions

See [Nested Functions](../../sql/functions/nested).

0 comments on commit e7dbd5b

Please sign in to comment.