{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/data/issues/2663","labels_url":"https://api.github.com/repos/emberjs/data/issues/2663/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/data/issues/2663/comments","events_url":"https://api.github.com/repos/emberjs/data/issues/2663/events","html_url":"https://github.com/emberjs/data/pull/2663","id":53431188,"number":2663,"title":"Checking superclass type for equality in addCanonicalRecord method for a belongsTo relationship","user":{"login":"oshikryu","id":1293288,"avatar_url":"https://avatars.githubusercontent.com/u/1293288?v=3","gravatar_id":"","url":"https://api.github.com/users/oshikryu","html_url":"https://github.com/oshikryu","followers_url":"https://api.github.com/users/oshikryu/followers","following_url":"https://api.github.com/users/oshikryu/following{/other_user}","gists_url":"https://api.github.com/users/oshikryu/gists{/gist_id}","starred_url":"https://api.github.com/users/oshikryu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oshikryu/subscriptions","organizations_url":"https://api.github.com/users/oshikryu/orgs","repos_url":"https://api.github.com/users/oshikryu/repos","events_url":"https://api.github.com/users/oshikryu/events{/privacy}","received_events_url":"https://api.github.com/users/oshikryu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-05T19:11:37Z","updated_at":"2015-01-06T21:33:41Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/emberjs/data/pulls/2663","html_url":"https://github.com/emberjs/data/pull/2663","diff_url":"https://github.com/emberjs/data/pull/2663.diff","patch_url":"https://github.com/emberjs/data/pull/2663.patch"},"body":"When using polymorphic models in an ember app, the `addCanonicalRecord` method does not check for a model's superclass when comparing equality of a `newRecord` to the expected `type`\r\n\r\nBecause there previously was no check for a type's super class, this assertion pops up: `Ember.assert(\"You can only add a '\" + type.typeKey + \"' record to this relationship\", newRecord instanceof type);`\r\n\r\nMy solution to this is to add a check for `Ember.MODEL_FACTORY_INJECTIONS` like in the `addRecord` method inside the `belongs_to` class:\r\n```\r\nEmber.assert(\"You can only add a '\" + type.typeKey + \"' record to this relationship\", (function () {\r\n    if (newRecord instanceof type) {\r\n      return true;\r\n    } else if (Ember.MODEL_FACTORY_INJECTIONS) {\r\n      return newRecord instanceof type.superclass;\r\n    }\r\n\r\n    return false;\r\n  })());\r\n```"},"comment":{"url":"https://api.github.com/repos/emberjs/data/issues/comments/68937793","html_url":"https://github.com/emberjs/data/pull/2663#issuecomment-68937793","issue_url":"https://api.github.com/repos/emberjs/data/issues/2663","id":68937793,"user":{"login":"igorT","id":715175,"avatar_url":"https://avatars.githubusercontent.com/u/715175?v=3","gravatar_id":"","url":"https://api.github.com/users/igorT","html_url":"https://github.com/igorT","followers_url":"https://api.github.com/users/igorT/followers","following_url":"https://api.github.com/users/igorT/following{/other_user}","gists_url":"https://api.github.com/users/igorT/gists{/gist_id}","starred_url":"https://api.github.com/users/igorT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igorT/subscriptions","organizations_url":"https://api.github.com/users/igorT/orgs","repos_url":"https://api.github.com/users/igorT/repos","events_url":"https://api.github.com/users/igorT/events{/privacy}","received_events_url":"https://api.github.com/users/igorT/received_events","type":"User","site_admin":false},"created_at":"2015-01-06T21:33:41Z","updated_at":"2015-01-06T21:33:41Z","body":"Can you amend the commit message then? :)"}}