{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/3534","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/3534/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/3534/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/3534/events","html_url":"https://github.com/sequelize/sequelize/issues/3534","id":68314968,"number":3534,"title":"Attributes modified in hooks are not saved","user":{"login":"Verdier","id":2900150,"avatar_url":"https://avatars3.githubusercontent.com/u/2900150?v=4","gravatar_id":"","url":"https://api.github.com/users/Verdier","html_url":"https://github.com/Verdier","followers_url":"https://api.github.com/users/Verdier/followers","following_url":"https://api.github.com/users/Verdier/following{/other_user}","gists_url":"https://api.github.com/users/Verdier/gists{/gist_id}","starred_url":"https://api.github.com/users/Verdier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Verdier/subscriptions","organizations_url":"https://api.github.com/users/Verdier/orgs","repos_url":"https://api.github.com/users/Verdier/repos","events_url":"https://api.github.com/users/Verdier/events{/privacy}","received_events_url":"https://api.github.com/users/Verdier/received_events","type":"User","site_admin":false},"labels":[{"id":28979678,"url":"https://api.github.com/repos/sequelize/sequelize/labels/bug","name":"bug","color":"d7e102","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2015-04-14T09:24:26Z","updated_at":"2017-11-29T20:48:30Z","closed_at":"2016-04-02T18:09:16Z","author_association":"CONTRIBUTOR","body":"If you add a hook to (for exemple) a `User` model, and save an instance of the model with some attributes modified, such as:\n\n``` javascript\nuser.email = 'toto@toto.com';\nuser.save();\n```\n\nAnd if you modify some user attributes into the (for exemple...) `afterValidate` hook:\n\n``` javascript\nfunction afterUserValidate(user) {\n  if(user.changed('email')) {\n    return u.md5(user.email).then((md5) => user.emailMd5 = md5);\n  }\n}\n```\n\nThe `emailMd5` attribute is not saved. This is because dirty attributes are computed before the _pre-save_ hooks.\n\nSo my question: could we imagine to compute dirty attributes **after** the _pre-save_ hooks?\n"},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/347991439","html_url":"https://github.com/sequelize/sequelize/issues/3534#issuecomment-347991439","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/3534","id":347991439,"user":{"login":"fflshield-jenkins","id":12415777,"avatar_url":"https://avatars1.githubusercontent.com/u/12415777?v=4","gravatar_id":"","url":"https://api.github.com/users/fflshield-jenkins","html_url":"https://github.com/fflshield-jenkins","followers_url":"https://api.github.com/users/fflshield-jenkins/followers","following_url":"https://api.github.com/users/fflshield-jenkins/following{/other_user}","gists_url":"https://api.github.com/users/fflshield-jenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/fflshield-jenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fflshield-jenkins/subscriptions","organizations_url":"https://api.github.com/users/fflshield-jenkins/orgs","repos_url":"https://api.github.com/users/fflshield-jenkins/repos","events_url":"https://api.github.com/users/fflshield-jenkins/events{/privacy}","received_events_url":"https://api.github.com/users/fflshield-jenkins/received_events","type":"User","site_admin":false},"created_at":"2017-11-29T20:48:30Z","updated_at":"2017-11-29T20:48:30Z","author_association":"NONE","body":"This bug still exists in 4.22.12.  If you set an attribute in a beforeUpdate hook that was not part of the original list of update fields, the updated field appears in the response but not in the database.\r\n\r\nYou can't call .save in a beforeUpdate hook b/c it creates an endless loop."}}
{"actor":{"display_login":"fflshield-jenkins"}}