-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(postgres, sqlite): add conflictWhere option to upsert #13411
Conversation
df4c9ff
to
ee6e62b
Compare
Update on this: I ended up implementing this in a fork, but IIRC there was an issue I had w/ it (I believe it was around the logic upsert uses to determine which conflict columns to use, which isn't in the scope of this PR). I want to verify that it wasn't an issue with this change itself before I merge it. |
d701ed0
to
d59c8c4
Compare
@allawesome497 What shall we do with this one? |
I'll need to resolve merge conflicts, but it should be fine. Now that #13723 is merged I think I'll also add a few more tests which test the combined behavi for some more specific use cases. |
…ome497/sequelize into add-upsert-conflictWhere
Waiting for reviewers atm; just bumped it in the sequelize slack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we need to do a thorough clean up of the different options upsert accepts but this is good
@ephys re-requesting review - had to patch for compatibility with main which dismissed your approval. |
…d-upsert-conflictWhere
Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
@WikiRik can you approve this again? the rebase dismissed it. |
Adds an option to set the where clause in the `ON CONFLICT` part of postgres/sqlite upserts. Backport of #13411.
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
conflictWhere
toQueryGenerator.prototype.insertQuery
. This is used to generate theON CONFLICT WHERE
part of the query (note: notON CONFLICT DO UPDATE WHERE
).Model.upsert
,conflictWhere
, This is passed to the query generator.Example use case:
Closes #13412.
TODO:
Add some tests which validate
conflictWhere
&conflictFields
work together properly.