Closed
Labels
type: bugDEPRECATED: replace with the "bug" issue type
Description
What are you doing?
I just want increment field of a model instance after scope query.
see codes below:
Movie.scope('bh').findOne({where:{id:1}}).then(movie=>{
movie.increment('fav_nums',{by:1})
})bh is name of a scope,defined by code below:
scopes: {
bh: {
attributes: { exclude: ['created_at', 'updated_at','deleted_at'] }
}
}What do you expect to happen?
when query ,i need this scope to exclude some attributes,after query,i just want increment a field of model instance 。but see the sql below,wrong sql generated。
What is actually happening?
very simple code ,but will cause sql errors。because the code above will be translated into sqls like this:
UPDATE movie SET fav_nums=fav_nums+ 1,exclude='created_at', 'updated_at', 'deleted_at',updated_at='2019-01-21 15:59:18' WHERE id = 1Obviously,the sql is wrong。
Dialect: mysql
__Dialect version:
__Database version:5.6
__Sequelize version: 5.2.12
__Tested with latest release:yes,5.2.12
Note : Your issue may be ignored OR closed by maintainers if it's not tested against latest version OR does not follow issue template.
Reacted by mhio and GYX
Activity
sushantdhiman commentedon Apr 8, 2019
Similar #10411 , #9572
test(increment): reproduce sequelize#10719
ALiangLiang commentedon Apr 9, 2019
reproduce: ALiangLiang@be03653
mhio commentedon Nov 13, 2019
Same problem in sqlite