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
option object shouldn't be updated internally. #4023
Conversation
This pr is for the following bug. |
@@ -477,7 +477,7 @@ Instance.prototype.save = function(options) { | |||
if (arguments.length > 1) { | |||
throw new Error('The second argument was removed in favor of the options object.'); | |||
} | |||
options = _.defaults(options || {}, { | |||
options = _.defaults({}, options || {}, { |
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.
I don't think we need options || {}
, options
should be fine
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.
Oh, exactly.
Looks good @smihica - do you mind adding a few tests. Preferrably unit tests, since they are faster. Something along the lines of stub(sequelize, 'query').returns(Promise.resolve([]));
var options = { ... }
model.reload(options);
expect(options).to.deep.equal({... } If you have too many problems trying to stub sequelize.query, integration tests that hit the db will be fine as well |
Yes, I'll try to add some tests later. thanks reviewing. |
@janmeier |
option object shouldn't be updated internally.
Solid work on the tests @smihica ! Thanks for this, and the other PR also :) |
I got "not-null constraint" error because the previous save(opt) call inserted "fields" into opt.
This may cause confusing errors.