QueryBuilder: Add upsert #48595
Labels
0. Needs triage
Pending check for reproducibility or if it fits our roadmap
enhancement
feature: database
Database related DB
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:
Possible use cases for upsert.
duplicate key value violates unique constraint
#19494The text was updated successfully, but these errors were encountered: