MySQL's insert query supports the IGNORE keyword, which is describe in the MySQL manual:
If you use the IGNORE keyword, errors that occur while executing the INSERT statement are ignored. For example, without IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in the table causes a duplicate-key error and the statement is aborted. With IGNORE, the row still is not inserted, but no error occurs. Ignored errors may generate warnings instead, although duplicate-key errors do not.
Currently, one cannot use db_insert() with this keyword—no method exists for attaching it to the query string. I'd like to consider adding an ignore() method to InsertQuery_mysql which will append ' IGNORE' to the end of insert queries.
This has at least one drawback: it is only applicable to the mysql db engine. We'd only be adding it to the InsertQuery_mysql class, but the mere existence of this method for one db engine may cause module creators to inadvertently make modules dependent on the MySQL backend.
A number of links to places where people have requested this functionality:
Needs work
10.1 ✨
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.