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

option object shouldn't be updated internally. #4023

Merged
merged 5 commits into from Aug 4, 2015

Conversation

smihica
Copy link
Contributor

@smihica smihica commented Jun 28, 2015

I got "not-null constraint" error because the previous save(opt) call inserted "fields" into opt.
This may cause confusing errors.

@smihica
Copy link
Contributor Author

smihica commented Jun 29, 2015

This pr is for the following bug.
#4011

@@ -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 || {}, {
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, exactly.

@janmeier
Copy link
Member

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

@smihica
Copy link
Contributor Author

smihica commented Jun 29, 2015

Yes, I'll try to add some tests later. thanks reviewing.

@smihica
Copy link
Contributor Author

smihica commented Aug 4, 2015

@janmeier
OK. I added tests and rebased. And all unit and integration tests were passed in my environment.

janmeier added a commit that referenced this pull request Aug 4, 2015
option object shouldn't be updated internally.
@janmeier janmeier merged commit 03008f7 into sequelize:master Aug 4, 2015
@janmeier
Copy link
Member

janmeier commented Aug 4, 2015

Solid work on the tests @smihica ! Thanks for this, and the other PR also :)

janmeier added a commit that referenced this pull request Aug 4, 2015
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