Repository navigation
Fix field name mapping issue for bulk create queries with ON DUPLICATE UPDATE - #9162
Conversation
… with ON DUPLICATE UPDATE (sequelize#9016)
| @private | ||
| */ | ||
| bulkInsertQuery(tableName, attrValueHashes, options, rawAttributes) { | ||
| bulkInsertQuery(tableName, fieldValueHashes, options, fieldMappedAttributes) { |
There was a problem hiding this comment.
Might seems like API change but internally this was already the case, attrValueHashes are actually values mapped by their field names. Same is true for rawAttributes. So I have renamed these arguments
| }); | ||
|
|
||
| expectsql(sql.bulkInsertQuery(User.tableName, [{ user_name: 'testuser', pass_word: '12345' }], { updateOnDuplicate: ['username', 'password', 'updatedAt'] }, User.rawAttributes), | ||
| expectsql(sql.bulkInsertQuery(User.tableName, [{ user_name: 'testuser', pass_word: '12345' }], { updateOnDuplicate: ['user_name', 'pass_word', 'updated_at'] }, User.fieldRawAttributesMap), |
There was a problem hiding this comment.
a breaking change?
What this test assumes seems incorrect to me, if records are mapped by field name so should updateOnDuplicate values. bulkInsertQuery should just use whatever data given to it to generate query as its a low level API, converting attributes to fields etc stuff should be handled at model level api.
I think it should be ok to merge this change, records are expected to be mapped by field name so should updateOnDuplicate
|
🎉 This PR is included in version 4.36.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Close #9016
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