{"action":"closed","number":2339,"pull_request":{"url":"https://api.github.com/repos/RestKit/RestKit/pulls/2339","id":49005685,"html_url":"https://github.com/RestKit/RestKit/pull/2339","diff_url":"https://github.com/RestKit/RestKit/pull/2339.diff","patch_url":"https://github.com/RestKit/RestKit/pull/2339.patch","issue_url":"https://api.github.com/repos/RestKit/RestKit/issues/2339","number":2339,"state":"closed","locked":false,"title":"Don't return deleted NSManagedObject objects from the in memory cache","user":{"login":"AgentFeeble","id":1794482,"avatar_url":"https://avatars.githubusercontent.com/u/1794482?v=3","gravatar_id":"","url":"https://api.github.com/users/AgentFeeble","html_url":"https://github.com/AgentFeeble","followers_url":"https://api.github.com/users/AgentFeeble/followers","following_url":"https://api.github.com/users/AgentFeeble/following{/other_user}","gists_url":"https://api.github.com/users/AgentFeeble/gists{/gist_id}","starred_url":"https://api.github.com/users/AgentFeeble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgentFeeble/subscriptions","organizations_url":"https://api.github.com/users/AgentFeeble/orgs","repos_url":"https://api.github.com/users/AgentFeeble/repos","events_url":"https://api.github.com/users/AgentFeeble/events{/privacy}","received_events_url":"https://api.github.com/users/AgentFeeble/received_events","type":"User","site_admin":false},"body":"I came across an issue when using ```RKInMemoryManagedObjectCache``` with ```RKAssignmentPolicyReplace``` for a to-many relationship, that was causing the objects in the relationship to get deleted when the json response matched the current values in the database, along with the log message ```Core Data: annotation: repairing missing delete propagation for to-many relationship``` (and some information about the relationship).\r\n\r\nI tracked the issue down to ```-[RKEntityByAttributeCache objectForObjectID:inContext:]```, which would return objects that had been deleted in order to satisfy the ```RKAssignmentPolicyReplace``` assignment policy, and then used to re-populate the relationship instead of creating new objects. I noticed a comment that assumed ```-[NSManagedObjectContext existingObjectWithID:error:]``` returns nil for a deleted object, which is not the case in my testing. I don't know if this used to be the case with older versions of iOS/OSX, but it is not the case now. \r\n\r\nThese changes ensure that ```-[RKEntityByAttributeCache objectForObjectID:inContext:]``` returns nil instead of an object that has been deleted in the given context, along with a test case.","created_at":"2015-10-28T13:32:31Z","updated_at":"2015-10-28T13:52:38Z","closed_at":"2015-10-28T13:52:38Z","merged_at":"2015-10-28T13:52:38Z","merge_commit_sha":"8eb3ffc3906eed262d7e814d33d2bdce02f7e28c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RestKit/RestKit/pulls/2339/commits","review_comments_url":"https://api.github.com/repos/RestKit/RestKit/pulls/2339/comments","review_comment_url":"https://api.github.com/repos/RestKit/RestKit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RestKit/RestKit/issues/2339/comments","statuses_url":"https://api.github.com/repos/RestKit/RestKit/statuses/7512827bbeb6e0dd377777bf9091b2bad43fc750","head":{"label":"AgentFeeble:in-memory-cache-fix","ref":"in-memory-cache-fix","sha":"7512827bbeb6e0dd377777bf9091b2bad43fc750","user":{"login":"AgentFeeble","id":1794482,"avatar_url":"https://avatars.githubusercontent.com/u/1794482?v=3","gravatar_id":"","url":"https://api.github.com/users/AgentFeeble","html_url":"https://github.com/AgentFeeble","followers_url":"https://api.github.com/users/AgentFeeble/followers","following_url":"https://api.github.com/users/AgentFeeble/following{/other_user}","gists_url":"https://api.github.com/users/AgentFeeble/gists{/gist_id}","starred_url":"https://api.github.com/users/AgentFeeble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgentFeeble/subscriptions","organizations_url":"https://api.github.com/users/AgentFeeble/orgs","repos_url":"https://api.github.com/users/AgentFeeble/repos","events_url":"https://api.github.com/users/AgentFeeble/events{/privacy}","received_events_url":"https://api.github.com/users/AgentFeeble/received_events","type":"User","site_admin":false},"repo":{"id":45111312,"name":"RestKit","full_name":"AgentFeeble/RestKit","owner":{"login":"AgentFeeble","id":1794482,"avatar_url":"https://avatars.githubusercontent.com/u/1794482?v=3","gravatar_id":"","url":"https://api.github.com/users/AgentFeeble","html_url":"https://github.com/AgentFeeble","followers_url":"https://api.github.com/users/AgentFeeble/followers","following_url":"https://api.github.com/users/AgentFeeble/following{/other_user}","gists_url":"https://api.github.com/users/AgentFeeble/gists{/gist_id}","starred_url":"https://api.github.com/users/AgentFeeble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AgentFeeble/subscriptions","organizations_url":"https://api.github.com/users/AgentFeeble/orgs","repos_url":"https://api.github.com/users/AgentFeeble/repos","events_url":"https://api.github.com/users/AgentFeeble/events{/privacy}","received_events_url":"https://api.github.com/users/AgentFeeble/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AgentFeeble/RestKit","description":"RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X","fork":true,"url":"https://api.github.com/repos/AgentFeeble/RestKit","forks_url":"https://api.github.com/repos/AgentFeeble/RestKit/forks","keys_url":"https://api.github.com/repos/AgentFeeble/RestKit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AgentFeeble/RestKit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AgentFeeble/RestKit/teams","hooks_url":"https://api.github.com/repos/AgentFeeble/RestKit/hooks","issue_events_url":"https://api.github.com/repos/AgentFeeble/RestKit/issues/events{/number}","events_url":"https://api.github.com/repos/AgentFeeble/RestKit/events","assignees_url":"https://api.github.com/repos/AgentFeeble/RestKit/assignees{/user}","branches_url":"https://api.github.com/repos/AgentFeeble/RestKit/branches{/branch}","tags_url":"https://api.github.com/repos/AgentFeeble/RestKit/tags","blobs_url":"https://api.github.com/repos/AgentFeeble/RestKit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AgentFeeble/RestKit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AgentFeeble/RestKit/git/refs{/sha}","trees_url":"https://api.github.com/repos/AgentFeeble/RestKit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AgentFeeble/RestKit/statuses/{sha}","languages_url":"https://api.github.com/repos/AgentFeeble/RestKit/languages","stargazers_url":"https://api.github.com/repos/AgentFeeble/RestKit/stargazers","contributors_url":"https://api.github.com/repos/AgentFeeble/RestKit/contributors","subscribers_url":"https://api.github.com/repos/AgentFeeble/RestKit/subscribers","subscription_url":"https://api.github.com/repos/AgentFeeble/RestKit/subscription","commits_url":"https://api.github.com/repos/AgentFeeble/RestKit/commits{/sha}","git_commits_url":"https://api.github.com/repos/AgentFeeble/RestKit/git/commits{/sha}","comments_url":"https://api.github.com/repos/AgentFeeble/RestKit/comments{/number}","issue_comment_url":"https://api.github.com/repos/AgentFeeble/RestKit/issues/comments{/number}","contents_url":"https://api.github.com/repos/AgentFeeble/RestKit/contents/{+path}","compare_url":"https://api.github.com/repos/AgentFeeble/RestKit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AgentFeeble/RestKit/merges","archive_url":"https://api.github.com/repos/AgentFeeble/RestKit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AgentFeeble/RestKit/downloads","issues_url":"https://api.github.com/repos/AgentFeeble/RestKit/issues{/number}","pulls_url":"https://api.github.com/repos/AgentFeeble/RestKit/pulls{/number}","milestones_url":"https://api.github.com/repos/AgentFeeble/RestKit/milestones{/number}","notifications_url":"https://api.github.com/repos/AgentFeeble/RestKit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AgentFeeble/RestKit/labels{/name}","releases_url":"https://api.github.com/repos/AgentFeeble/RestKit/releases{/id}","created_at":"2015-10-28T12:37:54Z","updated_at":"2015-10-28T12:38:00Z","pushed_at":"2015-10-28T13:05:48Z","git_url":"git://github.com/AgentFeeble/RestKit.git","ssh_url":"git@github.com:AgentFeeble/RestKit.git","clone_url":"https://github.com/AgentFeeble/RestKit.git","svn_url":"https://github.com/AgentFeeble/RestKit","homepage":"","size":68396,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"development"}},"base":{"label":"RestKit:development","ref":"development","sha":"7a5b7e832c44222c3f8a1f1f6546263baf816f88","user":{"login":"RestKit","id":903233,"avatar_url":"https://avatars.githubusercontent.com/u/903233?v=3","gravatar_id":"","url":"https://api.github.com/users/RestKit","html_url":"https://github.com/RestKit","followers_url":"https://api.github.com/users/RestKit/followers","following_url":"https://api.github.com/users/RestKit/following{/other_user}","gists_url":"https://api.github.com/users/RestKit/gists{/gist_id}","starred_url":"https://api.github.com/users/RestKit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RestKit/subscriptions","organizations_url":"https://api.github.com/users/RestKit/orgs","repos_url":"https://api.github.com/users/RestKit/repos","events_url":"https://api.github.com/users/RestKit/events{/privacy}","received_events_url":"https://api.github.com/users/RestKit/received_events","type":"Organization","site_admin":false},"repo":{"id":508845,"name":"RestKit","full_name":"RestKit/RestKit","owner":{"login":"RestKit","id":903233,"avatar_url":"https://avatars.githubusercontent.com/u/903233?v=3","gravatar_id":"","url":"https://api.github.com/users/RestKit","html_url":"https://github.com/RestKit","followers_url":"https://api.github.com/users/RestKit/followers","following_url":"https://api.github.com/users/RestKit/following{/other_user}","gists_url":"https://api.github.com/users/RestKit/gists{/gist_id}","starred_url":"https://api.github.com/users/RestKit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RestKit/subscriptions","organizations_url":"https://api.github.com/users/RestKit/orgs","repos_url":"https://api.github.com/users/RestKit/repos","events_url":"https://api.github.com/users/RestKit/events{/privacy}","received_events_url":"https://api.github.com/users/RestKit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RestKit/RestKit","description":"RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X","fork":false,"url":"https://api.github.com/repos/RestKit/RestKit","forks_url":"https://api.github.com/repos/RestKit/RestKit/forks","keys_url":"https://api.github.com/repos/RestKit/RestKit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RestKit/RestKit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RestKit/RestKit/teams","hooks_url":"https://api.github.com/repos/RestKit/RestKit/hooks","issue_events_url":"https://api.github.com/repos/RestKit/RestKit/issues/events{/number}","events_url":"https://api.github.com/repos/RestKit/RestKit/events","assignees_url":"https://api.github.com/repos/RestKit/RestKit/assignees{/user}","branches_url":"https://api.github.com/repos/RestKit/RestKit/branches{/branch}","tags_url":"https://api.github.com/repos/RestKit/RestKit/tags","blobs_url":"https://api.github.com/repos/RestKit/RestKit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RestKit/RestKit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RestKit/RestKit/git/refs{/sha}","trees_url":"https://api.github.com/repos/RestKit/RestKit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RestKit/RestKit/statuses/{sha}","languages_url":"https://api.github.com/repos/RestKit/RestKit/languages","stargazers_url":"https://api.github.com/repos/RestKit/RestKit/stargazers","contributors_url":"https://api.github.com/repos/RestKit/RestKit/contributors","subscribers_url":"https://api.github.com/repos/RestKit/RestKit/subscribers","subscription_url":"https://api.github.com/repos/RestKit/RestKit/subscription","commits_url":"https://api.github.com/repos/RestKit/RestKit/commits{/sha}","git_commits_url":"https://api.github.com/repos/RestKit/RestKit/git/commits{/sha}","comments_url":"https://api.github.com/repos/RestKit/RestKit/comments{/number}","issue_comment_url":"https://api.github.com/repos/RestKit/RestKit/issues/comments{/number}","contents_url":"https://api.github.com/repos/RestKit/RestKit/contents/{+path}","compare_url":"https://api.github.com/repos/RestKit/RestKit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RestKit/RestKit/merges","archive_url":"https://api.github.com/repos/RestKit/RestKit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RestKit/RestKit/downloads","issues_url":"https://api.github.com/repos/RestKit/RestKit/issues{/number}","pulls_url":"https://api.github.com/repos/RestKit/RestKit/pulls{/number}","milestones_url":"https://api.github.com/repos/RestKit/RestKit/milestones{/number}","notifications_url":"https://api.github.com/repos/RestKit/RestKit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RestKit/RestKit/labels{/name}","releases_url":"https://api.github.com/repos/RestKit/RestKit/releases{/id}","created_at":"2010-02-09T01:14:06Z","updated_at":"2015-10-28T13:13:03Z","pushed_at":"2015-10-28T13:52:39Z","git_url":"git://github.com/RestKit/RestKit.git","ssh_url":"git@github.com:RestKit/RestKit.git","clone_url":"https://github.com/RestKit/RestKit.git","svn_url":"https://github.com/RestKit/RestKit","homepage":"","size":68396,"stargazers_count":8906,"watchers_count":8906,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2063,"mirror_url":null,"open_issues_count":269,"forks":2063,"open_issues":269,"watchers":8906,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/RestKit/RestKit/pulls/2339"},"html":{"href":"https://github.com/RestKit/RestKit/pull/2339"},"issue":{"href":"https://api.github.com/repos/RestKit/RestKit/issues/2339"},"comments":{"href":"https://api.github.com/repos/RestKit/RestKit/issues/2339/comments"},"review_comments":{"href":"https://api.github.com/repos/RestKit/RestKit/pulls/2339/comments"},"review_comment":{"href":"https://api.github.com/repos/RestKit/RestKit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RestKit/RestKit/pulls/2339/commits"},"statuses":{"href":"https://api.github.com/repos/RestKit/RestKit/statuses/7512827bbeb6e0dd377777bf9091b2bad43fc750"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"segiddins","id":1946610,"avatar_url":"https://avatars.githubusercontent.com/u/1946610?v=3","gravatar_id":"","url":"https://api.github.com/users/segiddins","html_url":"https://github.com/segiddins","followers_url":"https://api.github.com/users/segiddins/followers","following_url":"https://api.github.com/users/segiddins/following{/other_user}","gists_url":"https://api.github.com/users/segiddins/gists{/gist_id}","starred_url":"https://api.github.com/users/segiddins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segiddins/subscriptions","organizations_url":"https://api.github.com/users/segiddins/orgs","repos_url":"https://api.github.com/users/segiddins/repos","events_url":"https://api.github.com/users/segiddins/events{/privacy}","received_events_url":"https://api.github.com/users/segiddins/received_events","type":"User","site_admin":false},"comments":1,"review_comments":0,"commits":1,"additions":25,"deletions":3,"changed_files":2}}