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

Commit 118b4e9d by Artem Committed by Sushant

Fix issues #6356 on master (#7170)

* fix ER_EMPTY_QUERY error on update with virtual fields for master

* fix review

* [ci skip] Changelog for #6356
1 parent d4f742a8
# Future
- [FIXED] Updating `VIRTUAL` field throw `ER_EMPTY_QUERY` [#6356](https://github.com/sequelize/sequelize/issues/6356)
- [FIXED] Fix `Instance.decrement` precision problems [#7112](https://github.com/sequelize/sequelize/pull/7112)
- [FIXED] MSSQL tedious debug regression fix when dialectOptions are not passed [#7130](https://github.com/sequelize/sequelize/pull/7130)
- [CHANGED] `setIsolationLevelQuery` to skip under MSSQL dialect, added debug listener for tedious [#7130](https://github.com/sequelize/sequelize/pull/7130)
......
......@@ -3451,7 +3451,8 @@ class Model {
return instance.save(includeOptions).then(() => this[include.association.accessors.set](instance, {save: false, logging: options.logging}));
});
}).then(() => {
if (!options.fields.length) return this;
const realFields = options.fields.filter((field) => !this.constructor._isVirtualAttribute(field));
if (!realFields.length) return this;
if (!this.changed() && !this.isNewRecord) return this;
const versionFieldName = _.get(this.constructor.rawAttributes[versionAttr], 'field') || versionAttr;
......
......@@ -1213,6 +1213,21 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
});
it('should not throw ER_EMPTY_QUERY if changed only virtual fields', function() {
const User = this.sequelize.define('User' + config.rand(), {
name: DataTypes.STRING,
bio: {
type: DataTypes.VIRTUAL,
get: () => 'swag'
}
}, {
timestamps: false
});
return User.sync({force: true}).then(() => (
User.create({ name: 'John', bio: 'swag 1' }).then((user) => user.update({ bio: 'swag 2' }).should.be.fulfilled)
));
});
});
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!