Skip to content

Revert deprecation of InsertQueryBuilder.onConflict #8168

Closed

Description

@botre

Feature Description

The Problem

InsertQueryBuilder.onConflict has been marked as deprecated.

There is a comment telling to "Use orIgnore or orUpdate".

The deprecated method (signature onConflict(statement: string)) is much more flexible, since you have full control over the statement, whereas the alternative methods are rather constrained (you can choose which columns you'd like to update on conflict but not HOW to update those columns).

Columns should be updatable in multiple ways on conflict: concatenation, incrementation, interpolation, etc...
This is possible with onConflict. Unfortunately, this isn't possible with the current implementations of orIgnore and orUpdate.

The Solution

Revert the deprecation.

Alternative solutions

  • The orIgnore and orUpdate could be refactored to be more flexible

Are you willing to resolve this issue by submitting a Pull Request?

  • ✅ Yes, I have the time, and I know how to start.

Activity

  1. enniogonzalez commented on Mar 15, 2022

    @enniogonzalez

    @botre any update on this?

  2. pleerock commented on Mar 15, 2022

    @pleerock
    Member

    in order to resolve this issue we must ask author of these changes about the motivation and suggest alternative solution.

  3. wanton7 commented on Mar 30, 2022

    @wanton7

    Both onConflict and orUpdate seem to be deprecated, what should I use instead?

  4. karladler commented on Apr 4, 2022

    @karladler

    Both onConflict and orUpdate seem to be deprecated, what should I use instead?

    In my understanding only the function taking an object as argument is deprecated, while the version with this signature is supposed to work:

    orUpdate(overwrite: string[], conflictTarget?: string | string[]): this;

  5. Ginden commented on Apr 5, 2022

    @Ginden
    Contributor

    I think it's related to WebStorm/Intelij IDEA bug - if one function/method signature is deprecated, WebStorm will mark all of them as deprecated.

  6. pleerock commented on Apr 5, 2022

    @pleerock
    Member

    I think this can be closed because #8829 added clarification on this issue.

  7. botre commented on Apr 5, 2022

    @botre
    Author

    I think you missed my point.

    The alternative methods you point us to are less flexible than the deprecated methods.

    Guess I'll just switch to raw SQL for my use case.

  8. pleerock commented on Apr 5, 2022

    @pleerock
    Member

    if so, I suggest to find and ping the author of these changes - ask the motivation of these changes and propose a new & better solution.

  9. eysi09 commented on Aug 31, 2023

    @eysi09

    @botre, did you make any progress here?

    I'm bumping into the exact same issue where I need to revert to using the deprecated onConflict function because the new orUpdate function is too limited (I need to use a WHERE clause with the DO UPDATE SET statement).

  10. ashrash commented on Nov 9, 2023

    @ashrash

    How do i implement the following aggregation which is possible in postgres

    ON CONFLICT(id, date) DO UPDATE SET seconds = seconds_passed.seconds + EXCLUDED.seconds` ?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions