The following bug has been logged on the website:
Bug reference: 18502
Logged by: Michael Wang
Email address: michael.wanghai.a@outlook.com
PostgreSQL version: 12.5
Operating system: Official docker Image run in MacOS 14.3
Description:
I have a table, index and view like following:
```
CREATE TABLE my_table
(
id uuid primary key,
data jsonb not null
);
CREATE UNIQUE INDEX ON my_table ((data ->> 'key'));
CREATE VIEW my_view AS SELECT * FROM my_table;
```
The upsert on view returns 42P10 error when I execute the following SQL
```
INSERT INTO my_view (id, data)
VALUES ('990cc75c-2e60-4c0d-8bec-9ac976dc03bc'::uuid,
'{
"key": "value"
}'::jsonb)
ON CONFLICT ((data ->> 'key'))
DO NOTHING;
```
I tested cast expression and fails as well
```
CREATE UNIQUE INDEX ON my_table ((id::text));
INSERT INTO my_view (id, data)
VALUES ('990cc75c-2e60-4c0d-8bec-9ac976dc03bc'::uuid,
'{
"key": "value"
}'::jsonb)
ON CONFLICT ((id::text))
DO NOTHING;
```
I also tested `DO UPDATE...`, the same error is returned.
I also tested with the latest official docker image witch is PG 16, same
error returns.