You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Including a virtual field with no other changed values gives an ER_EMPTY_QUERY error #6356
varSequelize=require('sequelize');vardatabase=newSequelize(/*fill in database configurations*/);varTestModel=database.define('TestModel',{realField: Sequelize.INTEGER,virtField: {type: Sequelize.VIRTUAL,get: function(){return4;}}},{tableName: 'test_model',timestamps: false});TestModel.sync();TestModel.create({realField: 8}).then(function(result){result.update({virtField: 4,realField: 6}).then(function(){console.log('When the instance has changed, it still works.');});result.update({virtField: 4}).then(function(){console.log('If virtField has a setter, this will print. Otherwise there\'ll be an error.');});});
What do you expect to happen?
Since Sequelize doesn't fuss when there's a virtual field without a setter in an update normally, I would assume that intended functionality would be for there to be no error.
What is actually happening?
As-is, my code will work fine for the first update call, the one that changes both realField and virtField. However, the second query will throw an error. It would seem that Sequelize doesn't handle it well when a changed virtual field with no setter is present in the returned object.
If there is a setter function present, e.g. js set: function() {}, there's no error.
It's worth noting that this may be unique to databases without timestamps, because timestamps will presumably always be updated.
Dialect: mysql Database version:[email protected] Sequelize version: 3.23.6
Activity
sushantdhiman commentedon Dec 3, 2016
VIRTUALfields should be removed before passing attributes for saving[ci skip] Changelog for sequelize#6356
V3 Fix issues #6356 (#7164)
Fix issues #6356 on master (#7170)
Fix issues sequelize#6356 on master (sequelize#7170)