Closed nicolasgoutaland closed 11 years ago
Your guess is correct and you are not missing anything. We made an assumption with the framework that the entire object graph would be synchronized. If you'd like to put together a pull request I'd be happy to merge it in.
best, Michael
Good. In order to fix this problem, I've updated the datamodel in order to retrieve distant object. Should I update the data model or do you prefer me to add a new model version, to allow lightweight migration ?
Regards
I'm not sure I follow why an update to the data model is necessary given your code change above. Can you elaborate?
On Mar 26, 2013, at 5:37 AM, gougou1 notifications@github.com wrote:
Good. In order to fix this problem, I've updated the datamodel in order to retrieve distant object. Should I update the data model or do you prefer me to add a new model version, to allow lightweight migration ?
Regards
— Reply to this email directly or view it on GitHub.
Hi.
In fact, I've updated the data model to perform relationship between synchronized and none synchronized entities.
I've added an interface implemented by non synchronized entities with relationship to synchronized one.
When serializing data, I compute a predicate in order to be able to rebuild the relationship on other devices.
For example, you manage cars. Each car has a brand (Ford, Chevrolet, etc...).
It's unusfull to sync brands, and it prevents from duplicate entries. But each car has a relationship to a brand. Each brand is unique and has an uid.
Regards
At this time that doesn't sound like a change that we're ready to pull into the framework, but feel free to point me to the diffs so I can take a look.
Hi,
To start, thanks for your awesome work, and to share it.
I'm testing your library with several scenarios, including relationships between synchronized and not synchronized object.
For example, I have 2 entities, A and B (How original ;)), and A inherits from TICDSSynchronizedManagedObject, while B not.
So, as far as I understand, only A will by synchronized. Next, I've added a to one relationship between A and B. The problem is that there is an exception thrown when saving modifications with this configuration.
The problem is that your library is looking for a ticdsSyncID attribute in my entity B.
The exception is only thrown for toOne relationships. So, I've managed to dig into your code to method createToOneRelationshipSyncChange: from TICDSSynchronizedManagedObject class.
My guess is that this method always create an TICDSSyncChange, even if destination entity isn't synchronized, that could cause the problem.
Here is my fix :
(void)createToOneRelationshipSyncChange:(NSRelationshipDescription )aRelationship { NSManagedObject relatedObject = [self valueForKey:[aRelationship name]];
// Check that the related object should be synchronized if(![relatedObject isKindOfClass:[TICDSSynchronizedManagedObject class]]) return;
TICDSSyncChange *syncChange = [self createSyncChangeForChangeType:TICDSSyncChangeTypeToOneRelationshipChanged];
TICDSLog(TICDSLogVerbosityManagedObjectOutput, @"[%@] %@", syncChange.objectSyncID, [self class]);
[syncChange setRelatedObjectEntityName:[[aRelationship destinationEntity] name]]; [syncChange setRelevantKey:[aRelationship name]]; [syncChange setChangedRelationships:[relatedObject valueForKey:TICDSSyncIDAttributeName]]; }
So, is my guess correct, or am I missing something ?
Thanks for your help.
Regards,