Repository navigation
Conversation
Add support for where clauses used in the ON CONFLICT part of the queries generated by model.bulkCreate and model.upsert for usage > Closes sequelize#13240, sequelize#13066, sequelize#13031, sequelize#12774, sequelize#12742, sequelize#12595, sequelize#11656
|
This feature will help us out, we currently have a custom upsert function that does this that this would replace |
wbourne0
force-pushed
the
wb-on-conflict-upsert
branch
from
May 30, 2021 00:36
fe7d513 to
707371e
Compare
mohanagy
previously approved these changes
Jun 7, 2021
Keimeno
reviewed
Jun 7, 2021
Member
|
Hello! Just to have it written here, as we discussed earlier on Slack: please split this PR in four parts, considering #13346 to be the first of them. The other three parts should be:
Note: maybe you can join the last two in a single PR if you want. |
Member
Author
|
Sounds good, going to close this now and break it up. I'll follow up and mention the other PRs once I make them. |
1 of 2 tasks
Member
Author
#13412 should take care of that. I'm currently working on a similar pr for |
6 tasks done
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for where clauses used in the ON CONFLICT part of the queries generated by model.bulkCreate and model.upsert for usage >
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
This is similar to #11611 but a bit different. Unique indexes partial on the records not being soft deleted (eg,
CREATE UNIQUE INDEX 'abc' ON 'table1' ("col1") WHERE time_deleted IS NULL) are picked up automatically so long as:conflictFields(for upsert,upsertFieldsfor bulkCreate, happy to change naming if needed)Model.upserthas 2 more options:conflictFields- This is for specifying the keys which are added inON CONFLICT(). (eg,ON CONFLICT(${conflictFields})).conflictWhere- This is used to specify a where clause for theON CONFLICTpart of the query.Model.bulkCreatehas the same options but with different names (might be worth changing them to match):upsertFields- Same thing asconflictFields.upsertWhere- Same asconflictWhere.Note: bulkCreate will ignore these options if
updateOnDuplicateisn't specified.An example case of where this is handy:
Closes #13240, #13066, #13031, #12774, #12742, #12595, #11656