-
-
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
fix(postgres, sqlite): map conflictFields to column names in Model.upsert #14199
Conversation
fixes an issue where the attributes provided in conflictFields wouldn't be mapped to column names.
20f1acc
to
7e79750
Compare
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.
Only change request :)
src/model.js
Outdated
options.conflictFields = options.conflictFields | ||
&& options.conflictFields.map( | ||
attr => (this.rawAttributes[attr] && this.rawAttributes[attr].field) || attr, | ||
); | ||
|
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.
just a small code style change
options.conflictFields = options.conflictFields | |
&& options.conflictFields.map( | |
attr => (this.rawAttributes[attr] && this.rawAttributes[attr].field) || attr, | |
); | |
options.conflictFields = options.conflictFields?.map( | |
attr => (this.rawAttributes[attr]?.field) || attr, | |
); | |
This piece of code is used a lot in sequelize. We could add a Model.getColumnName(attributeName: string): string
util which does this
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.
Do we want to add Model.getColumnName(attributeName: string): string
in this PR already?
…x-upsert-conflictFields
…ize/sequelize into fix-upsert-conflictFields
…x-upsert-conflictFields
…ize/sequelize into fix-upsert-conflictFields
@@ -2544,6 +2544,10 @@ Specify a different name for either index to resolve this issue.`); | |||
const updateValues = Utils.mapValueFieldNames(updatedDataValues, options.fields, this); | |||
const now = Utils.now(this.sequelize.dialect); | |||
|
|||
options.conflictFields = options.conflictFields?.map( | |||
attr => (this.rawAttributes[attr]?.field) || attr, |
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.
Since this is a breaking change, should we rename conflictFields
to conflictAttributes
in this PR? (see comment in #13419)
This pull request has been marked as maybe-abandoned and has not seen any activity for 14 days. It will be closed if no further activity occurs within the next 30 days. If you would still like to work on this, please comment to let us know and the label will be removed. |
Can we re-open this PR and merge? This fix can land in v7. |
@muraliprajapati Some further updates might need to be done in order to merge this since it's been a year since the last update. We've done quite some work internally since then. Feel free to open a new PR that adds this feature and new tests to the current codebase |
Pull Request Checklist
Please make sure to review and check all of these items:
yarn test
oryarn test-DIALECT
pass with this change (including linting)?Description Of Change
fixes an issue where the attributes provided in conflictFields wouldn't be mapped to column names.
Closes #14150