caiyue1993/IceCream

One to many relation ship is not working properly

abhi12340 opened this issue ยท 6 comments

Below is the issue template. You can fill each part then submit your issue.
Or you can just delete all of these and describe your questions in you-like style.
But please remember: the more detailed info you offered, the greater possibility your problem will be solved. ๐Ÿ˜œ

Expected behavior

I am trying to sync data from my local realm DB to a cloud kit database via ice cream that has a scope of private. One model has a one-to-many relationship. Where ever I sync data from the cloud kit via Ice cream weather on iPad, iPhone, etc. Sync should respect the one-to-many relationship. For example, if one Person A has 2 cats and Person B has 3 cats and Person C has 1 cat at the time of sync from local realm to cloud kit it should be the same when we sync from cloud kit to device (realm local DB).

Actual behavior(optional)

Sync from cloud kit via icecream to Device does not respect the one-to-many relationship as Person A has 2 cats and Person B has 3 cats in local realm DB, So if I delete the application that time local realm DB will be deleted and it will sync data from cloud kit after syncing from cloud kit it is not proper like Person B some time has 1 cat or no cat and A has all the cat-like not respecting the relationship.

As I Did proper setup for icecream

// Please replace this line with the actual behavior.

Steps to reproduce the problem(optional)

// Please provided to steps to reproduce the problem

Reference links(optional)

// Please offer the reference links to us. We appreciate it.

Hi @abhi12340. I experience a similar issue: One of my objects has two one-to-many relationships and usually one of those relationships is broken after the app reinstall. It usually occurs when the list has more than 15-20 entries.
Have you managed to fix it?

@caiyue1993 do you have any thoughts on these issues?

Hi, I use an alternative way for this problem as this problem is with the custom data type not with primitive data type for eg:- Array of a string so while sync I am sending the array of the id of the one to many objects in the cloud sync not the array of object and at the time of syncing getting object from the id and writing to the realm. This workaround I implemented to deal with the issue.

Thanks for your response @abhi12340.
As I understand, IceCream framework relationship sync should not only work with primitive types but also with any Object subclass (In the example provided there is a list of Cat objects). So I think it is an issue in the framework. Hope it will be fixed soon.

Yes you are correct it is bug from framework in future might get fixed but you can do workaround mentioned above.

@caiyue1993 I think I found the issue, please look at my PR.

Hi @abhi12340, thank you for submitting this issue. Indeed this is a bug in the framework.
And as @yulian948 commented, the bug may happen when the list has quite a lot elements. #233 has fixed this issue and already been merged! Please refer to #233 for the details. Thank you guys!