Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationships recover but not to the original parent class #238

Closed
mohitnandwani opened this issue Jun 12, 2021 · 11 comments · Fixed by #240
Closed

Relationships recover but not to the original parent class #238

mohitnandwani opened this issue Jun 12, 2021 · 11 comments · Fixed by #240
Assignees
Labels

Comments

@mohitnandwani
Copy link

Expected behavior

Relationships should recover properly to the records/objects they belong.

Actual behavior

Relationships recover but not to the original parent class. Instead they get added to random objects and update records in CloudKit causing loss of original data.

Steps to reproduce the problem

• Use example to add data and sync it with CloudKit
• Uninstall the app and delete all files
• Reinstall app and let it recover data from CloudKit and you'll see relationships not recovering properly and get added to random objects
• Visit CloudKit dashboard and you'll find that your data is now updated with new/wrong relationships

@mohitnandwani mohitnandwani changed the title Issue while recovering relationships (Both to-one and to-many) Relationships recover but not to the original parent class Jun 12, 2021
@caiyue1993 caiyue1993 self-assigned this Jun 16, 2021
@caiyue1993 caiyue1993 added the bug label Jun 16, 2021
@caiyue1993
Copy link
Owner

caiyue1993 commented Jun 16, 2021

Hi @mohitnandwani , really appreciate it for proposing this issue and I've noticed this bug as well. I'll take some time to fix it and will let you know.

@caiyue1993
Copy link
Owner

caiyue1993 commented Jun 16, 2021

And I've found the CloudKit Console(which was CloudKit dashboard) always shows the below error message when I try to query records:

"Field 'recordName' is not marked queryable"

I've tried some ways to make it work but it failed. Have you guys encountered this problem?

@mohitnandwani
Copy link
Author

Hey @caiyue1993 , Thanks for your reply! Yeah it does show the error when querying records on CloudKit without any filter. What I usually do is to query records with "isDeleted" filter in the new console. Also it seems that the bug happen with the pendingRelationshipWorker appending relationship to random objects during the first sync. (Inside the CKRecordRecoverable, when its converting the CKReference to List).

caiyue1993 added a commit that referenced this issue Jun 27, 2021
@caiyue1993
Copy link
Owner

caiyue1993 commented Jun 27, 2021

Hi @mohitnandwani , thanks for your suggestion! Now I can successfully query records in CloudKit Console. And I think I've found the reason behind this relationships recover issue. I've submitted PR #240.
The fix branch name is fix/issue-238. How about giving it a try when you have time? We'll merge that PR if it fixes.
Thank you again!

@mohitnandwani
Copy link
Author

mohitnandwani commented Jun 27, 2021

Hey @caiyue1993 👋🏽! Thank you so much for looking into this! Will definitely look into this and get back to you as soon as I can!

@elliotcz97
Copy link

@caiyue1993 I used your fix in the PR #240 yesterday, because i had the same problem as the OP!
It fixed the issue, now the list elements don't spread randomly across other parents lists. I tested it only Yesterday, but if you want i can give a long term review after the weekend!

@caiyue1993
Copy link
Owner

caiyue1993 commented Jul 10, 2021

Thank you @elliotcz97! Sorry for the delayed response. Yes please give it a long term review and give us your feedback when you have time!

@elliotcz97
Copy link

elliotcz97 commented Jul 10, 2021

@caiyue1993
So, to be short it works great, and it fixes the problem, however what i noticed, that the list elements get rearanged, for example if i have list:

  • Eggs
  • Milk
  • Butter

Then after upload i could get:

  • Butter
  • Egg
  • Milk

And i think, for now, i cannot confirm it, but i have a feeling that my problem #242 has to do something with this.
To be short if i alter a list item on one device, then it gets uploaded, but the old item on the other device gets pulled back after a while.
(this happens only with clases containing relationships, so thats why i think it could be related)

@caiyue1993
Copy link
Owner

Hi @elliotcz97, yeah it may be the same cause. As for the rearranged elements it's acceptable. You could add index property onto every element to order them.
So, #240 is ready to be merged. Thank you all!

caiyue1993 added a commit that referenced this issue Jul 18, 2021
@elliotcz97
Copy link

@caiyue1993 thanks for your idea, i already did that ( giving index property). I hope you can find a solution for my issue too, Have a nice day.

wkhandev added a commit to inwardinsight/IceCream that referenced this issue Aug 30, 2021
* fix issue caiyue1993#238

* bump version

* add version control to RealmSwift dependency

Co-authored-by: Yue Cai <[email protected]>
Co-authored-by: Sol Cai <[email protected]>
@kyashan
Copy link

kyashan commented Jul 6, 2023

Hi @elliotcz97, yeah it may be the same cause. As for the rearranged elements it's acceptable. You could add index property onto every element to order them. So, #240 is ready to be merged. Thank you all!

I have the same problem with random reordering of list elements. Any solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants