Repository navigation
feat(postgres, sqlite): allow override of conflict keys in Model.bulkCreate - #13419
Conversation
366d8ac to
949997d
Compare
|
Wanted to note here that this feature doesn't seem to properly support the e.g. Floob.init(
{
someField: {
type: DataTypes.TEXT,
},
},
{
sequelize,
underscored: true,
}
);
Floob.bulkCreate(
// ...
{
conflictFields: ['someField'],
}
// ...
);
// -> SequelizeDatabaseError: column "someField" does not exist(also, you get a type error trying to list the snake case version of the fields in the new attribute, since they're not properties of the model) |
This should be fixed now. |
Adds an option to override the `upsertKeys` array passed to the query generator via setting `conflictFields`. Adds some TS tests for Model.bulkCreate.
e851dc0 to
265fd22
Compare
ephys
left a comment
There was a problem hiding this comment.
Looks good. It has a failing unit test that tries to access the database
This comment is also relevant #13411 (comment) :)
|
@ephys ping |
|
is anything blocking to merge this in? :) |
|
When this PR will be approved ? |
Missed these @nguyenphuocnhatthanh @Phillip-Kemper. I was a bit busy & stopped checking in on these for a while. Now that #13411 has been merged I'll be prioritizing this more then #13420. |
Adds the conflictAttributes option to Model.bulkCreate. Backport of #13419
Adds the conflictAttributes option to Model.bulkCreate. Backport of #13419
Adds the conflictAttributes option to Model.bulkCreate. Backport of #13419
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Allows for the override of the
upsertKeysvalue passed to the query generator viaoptions.conflictFields(forModel.bulkCreate).Note that the different name is intentional -
upsertKeysisn't as clear asconflictFieldsIMO. (its unclear whether anupsertKeyis referring to a key that will be updated or a key that should cause the existing row to be updated if it matches)This is a part of #13270 and it is needed for
conflictWhereto work (properly at least) in some cases. Though it is worth noting that there should be better logic for determining defaults, I think this is still handy for special edge cases.Example use case (using a many:many joiner table)