linq2db
linq2db copied to clipboard
Suggestion: BulkCopy with ON CONFLICT
I have a situation that is illustrated by following example:
CREATE TABLE IF NOT EXISTS "item"
(
id INT NOT NULL,
code VARCHAR(100) NOT NULL,
CONSTRAINT pk_item PRIMARY KEY (id)
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_item_code ON item USING btree (code);
Now I want to do a bulk insert by ignore duplicates on unique column "code" and it can be done like this:
INSERT INTO item(id,code)
VALUES (1,'1'),(2,'2'),(3,'2'),(4,'4')
ON CONFLICT DO NOTHING;
Existing BulkCopy method does not have an option to add ON CONFLICT at the end of statement. Is it possible to add this option?
It is possible. PR is welcome, as we probably will not have it on our list soon.
Is this specific database feature?
postgres and sqlite
We can add a database specific option.