{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/data/issues/3640","repository_url":"https://api.github.com/repos/emberjs/data","labels_url":"https://api.github.com/repos/emberjs/data/issues/3640/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/data/issues/3640/comments","events_url":"https://api.github.com/repos/emberjs/data/issues/3640/events","html_url":"https://github.com/emberjs/data/issues/3640","id":100472947,"number":3640,"title":"BelongsTo seems not update canonicalRecord when it is set to null","user":{"login":"SelokYeung","id":13759324,"avatar_url":"https://avatars.githubusercontent.com/u/13759324?v=3","gravatar_id":"","url":"https://api.github.com/users/SelokYeung","html_url":"https://github.com/SelokYeung","followers_url":"https://api.github.com/users/SelokYeung/followers","following_url":"https://api.github.com/users/SelokYeung/following{/other_user}","gists_url":"https://api.github.com/users/SelokYeung/gists{/gist_id}","starred_url":"https://api.github.com/users/SelokYeung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SelokYeung/subscriptions","organizations_url":"https://api.github.com/users/SelokYeung/orgs","repos_url":"https://api.github.com/users/SelokYeung/repos","events_url":"https://api.github.com/users/SelokYeung/events{/privacy}","received_events_url":"https://api.github.com/users/SelokYeung/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-12T05:56:02Z","updated_at":"2016-03-27T23:43:51Z","closed_at":"2016-03-27T23:43:51Z","body":"I was trying to rollback a relationship, and I found that canonicalRecord didn't update after save if it's value is set to null.  I don't know whether it is issue, but it is weird for canonicalRecord still keep the invalid record after save.\r\n\r\n[data/packages/ember-data/lib/system/relationships/state/belongs-to.js](https://github.com/emberjs/data/blob/v1.13.7/packages/ember-data/lib/system/relationships/state/belongs-to.js#L34)\r\n\r\nI guess it should be modify as follow\r\n```javascript\r\nBelongsToRelationship.prototype.setCanonicalRecord = function (newRecord) {\r\n\tif (newRecord) {\r\n\t\tthis.addCanonicalRecord(newRecord);\r\n\t} else {\r\n\t\tthis.removeCanonicalRecord(this.canonicalState);\r\n\t\tif (this.inverseRecord) {\r\n\t\t\tthis.removeCanonicalRecord(this.inverseRecord);\r\n\t\t}\r\n\t}\r\n\tthis.setHasData(true);\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/emberjs/data/issues/comments/202169454","html_url":"https://github.com/emberjs/data/issues/3640#issuecomment-202169454","issue_url":"https://api.github.com/repos/emberjs/data/issues/3640","id":202169454,"user":{"login":"bmac","id":54056,"avatar_url":"https://avatars.githubusercontent.com/u/54056?v=3","gravatar_id":"","url":"https://api.github.com/users/bmac","html_url":"https://github.com/bmac","followers_url":"https://api.github.com/users/bmac/followers","following_url":"https://api.github.com/users/bmac/following{/other_user}","gists_url":"https://api.github.com/users/bmac/gists{/gist_id}","starred_url":"https://api.github.com/users/bmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmac/subscriptions","organizations_url":"https://api.github.com/users/bmac/orgs","repos_url":"https://api.github.com/users/bmac/repos","events_url":"https://api.github.com/users/bmac/events{/privacy}","received_events_url":"https://api.github.com/users/bmac/received_events","type":"User","site_admin":false},"created_at":"2016-03-27T23:43:51Z","updated_at":"2016-03-27T23:43:51Z","body":"Resolved via 8400b9ddbce36f7d93c5b519eda974e46f612fd8"}}