Skip to content
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(model): fix unchained promise in association logic in bulkCreate #12163

Merged
merged 2 commits into from Apr 25, 2020

Conversation

SimonSchick
Copy link
Contributor

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Found this while messing around in code base.
Wrote no test due to high complexity of function, plus nothing seems to be failing as a result...

@codecov
Copy link

codecov bot commented Apr 24, 2020

Codecov Report

Merging #12163 into master will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12163      +/-   ##
==========================================
- Coverage   96.34%   96.32%   -0.03%     
==========================================
  Files          95       95              
  Lines        9203     9203              
==========================================
- Hits         8867     8865       -2     
- Misses        336      338       +2     
Impacted Files Coverage Δ
lib/model.js 96.60% <100.00%> (ø)
lib/dialects/postgres/connection-manager.js 94.44% <0.00%> (-1.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69c269b...5e6d594. Read the comment docs.

@@ -2642,7 +2642,7 @@ class Model {
const associationInstance = createdAssociationInstances[idx];
const instance = associationInstanceIndexToInstanceMap[idx];

instance[include.association.accessors.set](associationInstance, { save: false, logging: options.logging });
await include.association.set(instance, associationInstance, { save: false, logging: options.logging });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save: false, means this will not return promise. So await is not useful here. Why accessors is being removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the set function were converted to async so they always return a promise now.
Using accessors.set was only used to look up the instance set method which is effectively just a proxy (see helpers.js:64) seemed redundant to me 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, it is an async method now. That make sense

@sushantdhiman sushantdhiman merged commit db20040 into master Apr 25, 2020
@sushantdhiman sushantdhiman deleted the fix/unchained-promise-in-bulk-create branch April 25, 2020 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants