Add ignore on duplicate key to insert query

Created on 11 November 2017, about 7 years ago
Updated 30 June 2024, 6 months ago

Problem

Currently there is no way to use an insert query with ignore when duplicate key is found.

Proposed resolution

I think the best way to implement it is the following:

  • Update the base insert class with a new method to set a boolean that will enable this functionality.
  • Update the MySQL insert class to use INSERT IGNORE when the boolean is set.
  • Update the PostgreSQL insert class to use INSERT ... ON CONFLICT DO NOTHING when the boolean is set. This brings the requirement of having version 9.5 or newer. Is this a problem? Could add an extra requirement to this specific functionality.
  • Update the SQLite insert class to use INSERT OR IGNORE when the boolean is set.

Remaining tasks

  1. Discuss the proposed solution
  2. Write a patch
  3. Review

I have also some idea's about duplicate key update solutions, but for now lets first handle this ticket.

Feature request
Status

Needs work

Version

11.0 🔥

Component
Database 

Last updated 2 days ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇳🇱Netherlands pdenooijer

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024