nagyistoce / maccode

Automatically exported from code.google.com/p/maccode
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

ZDSMigrationHandler fails to copy relationships to target objects that it has not also copied to the new database #28

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I found that, in using ZDSMigrationHandler, between two schemas where the only 
difference is a 
few added columns, that a lot of the relationships that existed in the old 
database were null in 
the new one. 

I investigated and put in a few NSLogs and it seems that, in performMigration, 
the 
newEntitiesReference dictionary only contains objects that have been handled 
already. So after 
we go to copy an object to the new managed object context, we pass this 
dictionary to copyRelationshipsFromManagedObject:withReference:. But if the 
target of the relationship does 
not exist in newEntitiesReference, the relationship ends up being null.

Example output:

2008-09-10 04:34:05.658 ShoveBox[1299:2e13] Starting migration flow
2008-09-10 04:34:05.668 ShoveBox[1299:2e13] Building source stack
2008-09-10 04:34:05.776 ShoveBox[1299:2e13] Building destination stack
2008-09-10 04:34:06.273 ShoveBox[1299:2e13] Starting migration
2008-09-10 04:34:06.274 ShoveBox[1299:2e13] Current entity name is Action, new 
entities 
reference has 0 items
2008-09-10 04:34:06.281 ShoveBox[1299:2e13] Current entity name is Condition, 
new entities 
reference has 1 items
2008-09-10 04:34:06.283 ShoveBox[1299:2e13] Current entity name is ContentBlob, 
new 
entities reference has 2 items
2008-09-10 04:34:06.417 ShoveBox[1299:2e13] Current entity name is Entry, new 
entities 
reference has 112 items
2008-09-10 04:34:06.458 ShoveBox[1299:2e13] Current entity name is Folder, new 
entities 
reference has 222 items

Possible solutions:
1. I'm being a moron and this isn't really a problem.
2. The migration helper can specify an array of entity names so that the 
dependent objects can 
be copied first.
3.  performMigration can be rewritten so that it does a double-pass: first 
copying over the 
objects, then copying over the relationships.

I'm happy to fix the issue, if indeed, it is an issue, but I thought I'd check 
here first.

Thanks!

Dan Grover
Wonder Warp Software
www.wonderwarp.com

Original issue reported on code.google.com by dan.grov...@gtempaccount.com on 10 Sep 2008 at 8:39

GoogleCodeExporter commented 9 years ago
If anyone wants my crummy fix (went with option #2), the files are attached. If 
I weren't in a hurry, I'd probably 
more deeply investigate this and use #3.

Original comment by dan.grov...@gtempaccount.com on 10 Sep 2008 at 9:09

Attachments: