New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update instance attribute in "beforeUpdate" hook #10332
Comments
Hum, I've got a |
Thanks for posting the solution. Close ticket? |
No it's not, if the field is updated into the |
Can you try with master @oktapodia ? |
Sure, The latest master release is for the v5 isn't it? Version master#0f0255eed3d88efb179a47fe7763b7309517428a has been used It's still the same, and the log output is not resolved anymore ($1, $2 and $3). Not working behavior// model.js
//...
hooks: {
beforeValidate: (instance) => {
if (instance.changed('plainPassword')) {
instance.encryptedPassword = hashPassword(instance.plainPassword);
}
},
beforeUpdate: (instance) => {
if (instance.changed('plainPassword')) {
instance.encryptedPassword = hashPassword(instance.plainPassword);
}
},
},
//... [0] Executing (default): UPDATE "user" SET "token"=$1,"updated_at"=$2 WHERE "id" = $3 Working behavior// model.js
//...
hooks: {
beforeUpdate: (instance) => {
if (instance.changed('plainPassword')) {
instance.encryptedPassword = hashPassword(instance.plainPassword);
}
},
//... [0] Executing (default): UPDATE "user" SET "token"=$1,"updated_at"=$2,"encrypted_password"=$3 WHERE "id" = $4 |
So |
Exactly sorry if I wasn't clear enough |
This is still an issue on v5 — we just encountered it where we're have |
Actually to be clear, we have other code in the |
Having similar issues here whereby I only have a beforeUpdate hook and trying to add a field in to update,
I would expect that ReadyToDispatchTimestamp would also be in the executed SQL statement but I get none. Executing (default): UPDATE I've tried making ReadyToDispatchTimestamp a string field and also a Date field, neither worked. Lost... |
Hello,
The beforeUpdate hook on single update (not related to individualHook) does not update the query
Link to #5821 but on single update (with
.save()
)What are you doing?
What do you expect to happen?
Update the SQL query via the beforeUpdate hook
What is actually happening?
The SQL query executed
Dialect: postgres
Dialect version: 7.7.1
Database version: 11
Sequelize version: 4.41.2
Tested with latest release: Yes
Thanks a lot
The text was updated successfully, but these errors were encountered: