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): create instance with many-to-many association with extra column (#10034) #10050

Merged
merged 2 commits into from Oct 23, 2018

Conversation

@tsasaki609
Copy link
Contributor

@tsasaki609 tsasaki609 commented Oct 20, 2018

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 follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

fix #10034
I tried to include extra attributes in the condition processing the scope.

if (attr === include.association.foreignKey || attr === include.association.otherKey) {
continue;
}
values[attr] = instance[include.association.through.model.name][attr];

This comment has been minimized.

@sushantdhiman

sushantdhiman Oct 21, 2018
Contributor

Check if instance[include.association.through.model.name][attr] is defined only then we should set values[attr]

if (include.association.through.model.rawAttributes[attr]._autoGenerated) {
continue;
}
if (attr === include.association.foreignKey || attr === include.association.otherKey) {

This comment has been minimized.

@sushantdhiman

sushantdhiman Oct 21, 2018
Contributor

Both if statements can be folded into single check?

@tsasaki609 tsasaki609 force-pushed the tsasaki609:add-extra-column branch from b7c01a4 to d22c974 Oct 21, 2018
@codecov
Copy link

@codecov codecov bot commented Oct 21, 2018

Codecov Report

Merging #10050 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10050      +/-   ##
==========================================
+ Coverage    96.3%    96.3%   +<.01%     
==========================================
  Files          63       63              
  Lines        9410     9415       +5     
==========================================
+ Hits         9062     9067       +5     
  Misses        348      348
Impacted Files Coverage Δ
lib/model.js 96.68% <100%> (+0.01%) ⬆️

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 a0545bf...74acd72. Read the comment docs.

@tsasaki609
Copy link
Contributor Author

@tsasaki609 tsasaki609 commented Oct 21, 2018

Thanks for the review. I fixed it.

Copy link
Contributor

@sushantdhiman sushantdhiman left a comment

Thanks, a few more changes and this should be good to go

expect(foo.bars[0].foobar).to.not.equal(null);
expect(foo.bars[0].foobar.baz).to.equal('baz...');
}, () => {
expect.fail();

This comment has been minimized.

@sushantdhiman

sushantdhiman Oct 21, 2018
Contributor

expect.fail is not required promise rejection will bubble up

}).then(() => {
return Foo.findOne({ include: Bar });
}).then(foo => {
expect(foo.name).to.equal('foo...');

This comment has been minimized.

@sushantdhiman

sushantdhiman Oct 21, 2018
Contributor

Please repeat these checks for data returned just after create as well

This comment has been minimized.

@tsasaki609

tsasaki609 Oct 21, 2018
Author Contributor

That makes sense.

@tsasaki609 tsasaki609 force-pushed the tsasaki609:add-extra-column branch from d22c974 to 2178bb7 Oct 21, 2018
@sushantdhiman sushantdhiman merged commit 5dc314b into sequelize:master Oct 23, 2018
4 checks passed
4 checks passed
@codecov
codecov/patch 100% of diff hit (target 96.3%)
Details
@codecov
codecov/project 96.3% (+<.01%) compared to a0545bf
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sushantdhiman
Copy link
Contributor

@sushantdhiman sushantdhiman commented Oct 23, 2018

Thanks @tsasaki609 👍

@papb
Copy link
Member

@papb papb commented Oct 24, 2018

Thank you very much @tsasaki609, excellent work! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants