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
I am calling .update on a sequelize model instance and it is in turn attempting to insert a new record with the provided fields. I cannot remember which version this started happening, but it seemed one day all of my .update calls triggered an insert query. Model.update, however works fine.
constuser=awaitUser.findOne({ ... });// This triggers a `INSERT INTO "users" ("field") VALUES("thing") ...`user.update({field: 'thing'});// This updates the model just fineUser.update({field: 'thing'},{where: {id: 1}});
What do you expect to happen?
The instance model should be updated
What is actually happening?
An INSERT query is called rather than an UPDATE query
"One day all of my .update calls triggered an insert query" not much to work with
This could happen when isNewRecord: true or model missing id(primary key). I need a proper SSCCE to reproduce and tag this as a bug
Please use Github Issue Tracker only for reporting bugs, requesting new features or discussions. Ask questions on Stackoverflow sequelize.js tag or Slack. While I would like to help answer any questions but it still take too much time.
If you are reporting a bug please isolate it as SSCCE, present it nicely and follow issue template. This will help maintainers and contributors understand your issue quickly.
If you are requesting a feature spend some time to properly present your use case with some examples, current and expected outcome.
I figured this would be an issue others were experiencing due to a recent version change, however I realized it is because of a change I made to the caching layer in my app. I am serializing the instance data and caching that, and then calling Model.build(data) after fetching from the cache. I then call update on this instance, so this must be causing the issue as build sets isNewRecord: true.
Activity
sushantdhiman commentedon Apr 6, 2018
"One day all of my .update calls triggered an insert query" not much to work with
This could happen when
isNewRecord: trueor model missingid(primary key). I need a proper SSCCE to reproduce and tag this as a bugPlease use Github Issue Tracker only for reporting bugs, requesting new features or discussions. Ask questions on Stackoverflow sequelize.js tag or Slack. While I would like to help answer any questions but it still take too much time.
If you are reporting a bug please isolate it as SSCCE, present it nicely and follow issue template. This will help maintainers and contributors understand your issue quickly.
If you are requesting a feature spend some time to properly present your use case with some examples, current and expected outcome.
( What is SSCCE ? You can find template for Sequelize here )
A few good example of SSCCE
removeAttribute('id')results inundefined: nulldata value #7318 (comment)ryanmcclure4 commentedon Apr 6, 2018
I figured this would be an issue others were experiencing due to a recent version change, however I realized it is because of a change I made to the caching layer in my app. I am serializing the instance data and caching that, and then calling Model.build(data) after fetching from the cache. I then call update on this instance, so this must be causing the issue as build sets
isNewRecord: true.