fix(model): create instance with many-to-many association with extra column (#10034) - #10050
Conversation
| if (attr === include.association.foreignKey || attr === include.association.otherKey) { | ||
| continue; | ||
| } | ||
| values[attr] = instance[include.association.through.model.name][attr]; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Both if statements can be folded into single check?
b7c01a4 to
d22c974
Compare
Codecov Report
@@ Coverage Diff @@
## master #10050 +/- ##
==========================================
+ Coverage 96.3% 96.3% +<.01%
==========================================
Files 63 63
Lines 9410 9415 +5
==========================================
+ Hits 9062 9067 +5
Misses 348 348
Continue to review full report at Codecov.
|
|
Thanks for the review. I fixed it. |
sushantdhiman
left a comment
There was a problem hiding this 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(); |
There was a problem hiding this comment.
expect.fail is not required promise rejection will bubble up
| }).then(() => { | ||
| return Foo.findOne({ include: Bar }); | ||
| }).then(foo => { | ||
| expect(foo.name).to.equal('foo...'); |
There was a problem hiding this comment.
Please repeat these checks for data returned just after create as well
There was a problem hiding this comment.
That makes sense.
d22c974 to
2178bb7
Compare
|
Thanks @tsasaki609 👍 |
|
Thank you very much @tsasaki609, excellent work! 😁 |
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
fix #10034
I tried to include extra attributes in the condition processing the scope.