support copyfrom with WHERE condition
- Dominant language
- Go
- Stars
- 14.3k
- Forks
- 1.1k
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 11
Description
I would like to use the copyfrom feature with a WHERE condition to avoid duplicate records in my destination table.
Here is the WHERE condition i would like to use (taken from a working rule for INSERT):
```
WHERE (EXISTS ( SELECT *
FROM asns
WHERE merchantId IS NOT DISTINCT FROM NEW.merchantId
AND return_provider IS NOT DISTINCT FROM NEW.return_provider
AND barcode IS NOT DISTINCT FROM NEW.barcode
AND carrier IS NOT DISTINCT FROM NEW.carrier
AND tracking_number IS NOT DISTINCT FROM NEW.tracking_number
AND customer_email IS NOT DISTINCT FROM NEW.customer_email
AND order_id IS NOT DISTINCT FROM NEW.order_id
AND order_name IS NOT DISTINCT FROM NEW.order_name
AND order_number IS NOT DISTINCT FROM NEW.order_number
AND return_line_item_id IS NOT DISTINCT FROM NEW.return_line_item_id
AND rma IS NOT DISTINCT FROM NEW.rma
AND sku IS NOT DISTINCT FROM NEW.sku)) DO INSTEAD NOTHING;
```
Thank you.
Contributor guide
Research direction
Start by reviewing pgx's CopyFrom entry point and PostgreSQL COPY semantics, then compare them with the INSERT rule shown in the issue. Done means a documented and tested way to apply an equivalent WHERE condition during copyfrom so duplicate destination records are avoided.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100