You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Revert deprecation of InsertQueryBuilder.onConflict #8168
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.
Reacted by JM, Daniyar Changylov, Dan, Azamatzhon Akhunzhanov, Micael Levi L. Cavalcante, Artem, Richard Strand, YuriiKovalenko, Lee Hansel Solevilla, Ogbu Nnamdi and 25 more
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).
Reacted by Matej Marecek, Daniil M, Angel and Petar Georgiev
Activity
enniogonzalez commentedon Mar 15, 2022
@botre any update on this?
pleerock commentedon Mar 15, 2022
in order to resolve this issue we must ask author of these changes about the motivation and suggest alternative solution.
wanton7 commentedon Mar 30, 2022
Both
onConflictandorUpdateseem to be deprecated, what should I use instead?karladler commentedon Apr 4, 2022
In my understanding only the function taking an object as argument is deprecated, while the version with this signature is supposed to work:
Ginden commentedon Apr 5, 2022
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.
pleerock commentedon Apr 5, 2022
I think this can be closed because #8829 added clarification on this issue.
botre commentedon Apr 5, 2022
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.
pleerock commentedon Apr 5, 2022
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.
eysi09 commentedon Aug 31, 2023
@botre, did you make any progress here?
I'm bumping into the exact same issue where I need to revert to using the deprecated
onConflictfunction because the neworUpdatefunction is too limited (I need to use aWHEREclause with theDO UPDATE SETstatement).ashrash commentedon Nov 9, 2023
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` ?