Skip to content

QueryBuilder: Add upsert #48595

Open
Enhancement
@kesselb

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:

Possible use cases for upsert.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions