不要怂,就是干,撸起袖子干!

Commit 39a4bd03 by Mick Hansen

Merge branch 'mbroadst-broken-updates'

2 parents 07b1dfd6 c7671687
......@@ -9,6 +9,7 @@
- [BUG] Fixed bad SQL when updating a JSON attribute with a different `field`
- [BUG] Fixed issue with creating and updating values of a `DataTypes.ARRAY(DataTypes.JSON)` attribute
- [BUG] `Model.bulkCreate([{}], {returning: true})` will now correctly result in instances with primary key values.
- [BUG] `instance.save()` with `fields: []` (as a result of `.changed()` being `[]`) will no result in a noop instead of an empty update query.
#### Backwards compatability changes
- `instance.update()` using default fields will now automatically also save and validate values provided via `beforeUpdate` hooks
......
......@@ -617,6 +617,8 @@ module.exports = (function() {
});
}
}).then(function() {
if (!options.fields.length) return this;
return self.QueryInterface[query].apply(self.QueryInterface, args)
.then(function(result) {
// Transfer database generated values (defaults, autoincrement, etc)
......
......@@ -93,6 +93,35 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
it('should succeed in updating when values are unchanged (without timestamps)', function() {
var User = this.sequelize.define('User' + config.rand(), {
name: DataTypes.STRING,
bio: DataTypes.TEXT,
email: DataTypes.STRING
}, {
timestamps: false
});
return User.sync({force: true}).then(function() {
return User.create({
name: 'snafu',
email: 'email'
}, {
fields: ['name', 'email']
}).then(function(user) {
return user.update({
name: 'snafu',
email: 'email'
});
}).then(function(user) {
return user.reload();
}).then(function(user) {
expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email');
});
});
});
it('should only save passed attributes', function () {
var user = this.User.build();
return user.save().then(function () {
......@@ -379,4 +408,4 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
});
});
\ No newline at end of file
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!