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

Commit 6b597dc2 by Artem Committed by Sushant

V3 Fix issues #6356 (#7164)

* fix 5755 for v3 branch

* fix ER_EMPTY_QUERY error on update with virtual fields

* fix review

* [ci skip] changelog for issue
1 parent 7fa00e0f
# 3.30.1 # 3.30.1
- [FIXED] `sourceKey` FOR `hasMany` now also works if a `where` was specified in an `include` [#7141](https://github.com/sequelize/sequelize/issues/7141) - [FIXED] `sourceKey` FOR `hasMany` now also works if a `where` was specified in an `include` [#7141](https://github.com/sequelize/sequelize/issues/7141)
- [CHANGED] Updated deprecated `node-uuid` package to `uuid` [#7148](https://github.com/sequelize/sequelize/pull/7148) - [CHANGED] Updated deprecated `node-uuid` package to `uuid` [#7148](https://github.com/sequelize/sequelize/pull/7148)
- [FIXED] Updating `VIRTUAL` field throw `ER_EMPTY_QUERY` [#6356](https://github.com/sequelize/sequelize/issues/6356)
# 3.30.0 # 3.30.0
- [FIXED] `removeColumn` method to support dropping primaryKey column (MSSQL) [#7081](https://github.com/sequelize/sequelize/pull/7081) - [FIXED] `removeColumn` method to support dropping primaryKey column (MSSQL) [#7081](https://github.com/sequelize/sequelize/pull/7081)
......
...@@ -650,7 +650,13 @@ Instance.prototype.save = function(options) { ...@@ -650,7 +650,13 @@ Instance.prototype.save = function(options) {
}); });
}) })
.then(function() { .then(function() {
if (!options.fields.length) return this; var realFields = [];
options.fields.forEach(function(field) {
if (!self.Model._isVirtualAttribute(field)) {
realFields.push(field);
}
});
if (!realFields.length) return this;
if (!this.changed() && !this.isNewRecord) return this; if (!this.changed() && !this.isNewRecord) return this;
var values = Utils.mapValueFieldNames(this.dataValues, options.fields, this.Model) var values = Utils.mapValueFieldNames(this.dataValues, options.fields, this.Model)
......
...@@ -1213,6 +1213,25 @@ describe(Support.getTestDialectTeaser('Instance'), function() { ...@@ -1213,6 +1213,25 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
}); });
}); });
}); });
it('should not throw ER_EMPTY_QUERY if changed only virtual fields', function() {
var User = this.sequelize.define('User' + config.rand(), {
name: DataTypes.STRING,
bio: {
type: DataTypes.VIRTUAL,
get: function() {
return 'swag';
}
}
}, {
timestamps: false
});
return User.sync({force: true}).then(function() {
return User.create({ name: 'John', bio: 'swag 1' }).then(function(user) {
return user.update({ bio: 'swag 2' }).should.be.fulfilled;
});
});
});
}); });
it('updates with function and column value', function() { it('updates with function and column value', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!