{"id":10114,"date":"2014-11-22T15:33:26","date_gmt":"2014-11-22T20:33:26","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10114"},"modified":"2015-03-10T16:22:30","modified_gmt":"2015-03-10T20:22:30","slug":"core-data-relationships-data-loss-bug","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/11\/22\/core-data-relationships-data-loss-bug\/","title":{"rendered":"Core Data Relationships Data Loss Bug"},"content":{"rendered":"<p><a href=\"https:\/\/twitter.com\/atomicbird\/status\/535945846517284864\">Tom Harrington<\/a> notes that <a href=\"https:\/\/devforums.apple.com\/message\/1052376#1052376\">several developers<\/a> (including <a href=\"https:\/\/twitter.com\/jamesdempsey\/status\/535946021553967104\">James Dempsey<\/a> and <a href=\"https:\/\/twitter.com\/siegel\/status\/535986429483319296\">Rich Siegel<\/a>) have encountered a bug with Core Data&rsquo;s <code>-[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:]<\/code> method. This is supposed to copy the data store from one location to another, e.g. for making a backup. The frameworks may also call the method on your behalf, e.g. if the user does a Save As. The bug is that, on Yosemite and iOS 8, the method discards many-to-many relationships. This is actually worse than corrupting the file because the new file will still be readable, so it may not be obvious that it&rsquo;s missing some of the data. The bug is reputed to affect all store types.<\/p>\r\n<p>(DropDMG and EagleFiler use Core Data but not many-to-many relationships, so I don&rsquo;t think they are affected.)<\/p>\r\n<p>Update (2014-11-24): <a href=\"https:\/\/twitter.com\/atomicbird\/status\/537004794989146112\">Harrington<\/a> has <a href=\"http:\/\/www.openradar.me\/radar?id=5521374336516096\">filed a bug<\/a> and posted a <a href=\"https:\/\/github.com\/atomicbird\/OpenRadar-Code\/tree\/master\/19074994\">sample project<\/a>.<\/p>\r\n<p>Update (2015-03-10): This is fixed in <a href=\"http:\/\/mjtsai.com\/blog\/2015\/01\/31\/mac-os-x-10-10-2\/\">Mac OS X 10.10.2<\/a> and <a href=\"https:\/\/twitter.com\/silvermana_\/status\/575274302901260288\">iOS<\/a> <a href=\"https:\/\/twitter.com\/silvermana_\/status\/575285219961405441\">8.2<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Tom Harrington notes that several developers (including James Dempsey and Rich Siegel) have encountered a bug with Core Data&rsquo;s -[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:] method. This is supposed to copy the data store from one location to another, e.g. for making a backup. The frameworks may also call the method on your behalf, e.g. if the user does [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[131,109,904,903,71],"class_list":["post-10114","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-coredata","tag-ios-8","tag-mac-os-x-10-10-yosemite","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=10114"}],"version-history":[{"count":6,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10114\/revisions"}],"predecessor-version":[{"id":10751,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10114\/revisions\/10751"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}