{"action":"created","issue":{"url":"https://api.github.com/repos/js-data/js-data/issues/383","repository_url":"https://api.github.com/repos/js-data/js-data","labels_url":"https://api.github.com/repos/js-data/js-data/issues/383/labels{/name}","comments_url":"https://api.github.com/repos/js-data/js-data/issues/383/comments","events_url":"https://api.github.com/repos/js-data/js-data/issues/383/events","html_url":"https://github.com/js-data/js-data/pull/383","id":168987195,"number":383,"title":"Inverse relation unlink bug","user":{"login":"pik","id":10236920,"avatar_url":"https://avatars.githubusercontent.com/u/10236920?v=3","gravatar_id":"","url":"https://api.github.com/users/pik","html_url":"https://github.com/pik","followers_url":"https://api.github.com/users/pik/followers","following_url":"https://api.github.com/users/pik/following{/other_user}","gists_url":"https://api.github.com/users/pik/gists{/gist_id}","starred_url":"https://api.github.com/users/pik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pik/subscriptions","organizations_url":"https://api.github.com/users/pik/orgs","repos_url":"https://api.github.com/users/pik/repos","events_url":"https://api.github.com/users/pik/events{/privacy}","received_events_url":"https://api.github.com/users/pik/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-08-02T20:59:17Z","updated_at":"2016-08-04T01:27:33Z","closed_at":"2016-08-04T01:27:33Z","pull_request":{"url":"https://api.github.com/repos/js-data/js-data/pulls/383","html_url":"https://github.com/js-data/js-data/pull/383","diff_url":"https://github.com/js-data/js-data/pull/383.diff","patch_url":"https://github.com/js-data/js-data/pull/383.patch"},"body":"ref: #376 Only the last commit is relevant (will rebase out after) but I built from my previous branch since I think the extraction helps readability. Basically JS-Data already goes down the `removeInverseRelation` pathway when a relation is set to `null/undefined` so `unlinkInverseRecords` is strictly unnecessary. \r\n\r\nFurther the code in `unlinkInverseRecords` is flawed (or it would only work correctly for `hasOne`:\r\n\r\n```es6\r\nutils.set(record, this.getInverse(this.mapper).localField, undefined)\r\n```\r\nCompare to (`removeInverseRelation`): \r\n```es6\r\nelse if (inverseDef.type === hasManyType) {\r\n  ...\r\n utils.remove(children, (child) => child === this || id === utils.get(child, idAttribute))\r\n```\r\n\r\nUnfortunately simply removing `removeInverseRelation` broke a test in the destroy suite. This is because the `hasOne` `setter()` does not clear correctly, so this was updated as well (see below). \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/js-data/js-data/issues/comments/237424793","html_url":"https://github.com/js-data/js-data/pull/383#issuecomment-237424793","issue_url":"https://api.github.com/repos/js-data/js-data/issues/383","id":237424793,"user":{"login":"pik","id":10236920,"avatar_url":"https://avatars.githubusercontent.com/u/10236920?v=3","gravatar_id":"","url":"https://api.github.com/users/pik","html_url":"https://github.com/pik","followers_url":"https://api.github.com/users/pik/followers","following_url":"https://api.github.com/users/pik/following{/other_user}","gists_url":"https://api.github.com/users/pik/gists{/gist_id}","starred_url":"https://api.github.com/users/pik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pik/subscriptions","organizations_url":"https://api.github.com/users/pik/orgs","repos_url":"https://api.github.com/users/pik/repos","events_url":"https://api.github.com/users/pik/events{/privacy}","received_events_url":"https://api.github.com/users/pik/received_events","type":"User","site_admin":false},"created_at":"2016-08-04T01:27:33Z","updated_at":"2016-08-04T01:27:33Z","body":"Will do. Closing this. "}}
{"actor":{"display_login":"pik"}}