Open
Description
Is your feature request related to a problem? Please describe.
PostgreSQL and MariaDB/MySQL will log a unique constraint violation in their logs (e.g. duplicate key value violates unique constraint for PostgreSQL). Even if the exception is handled in our application code, the log will still clutter the logs.
We introduced insertIgnoreConflict
to suppress the error, but it still requires two SQL statements. Nicer would be to add support for upserts to our query builder.
Doctrine DBAL does not support upserts.
Laravel supports upsert:https://github.com/laravel/framework/pull/34698/files
Upsert is not standardized, and thus the actual query looks different for each vendor:
- MariaDB: https://mariadb.com/kb/en/insert-on-duplicate-key-update/
- PostgreSQL: https://www.postgresql.org/docs/current/sql-insert.html (see "ON CONFLICT")
- SQLite: https://sqlite.org/lang_upsert.html
- Oracle: Try to use merge or fallback to insert + update
Possible use cases for upsert.
Activity