itsniper / FTASync

Allows you to sync CoreData entities with a Parse backend.
MIT License
311 stars 59 forks source link

Many too Many relationships tested #7

Closed cleqo closed 11 years ago

cleqo commented 11 years ago

Removing the FSALog and Assertion and adding the break will do the trick, currently i'm using it with three many to many objects and its working just fine (sometimes it duplicates objects, but i haven't been able to detect when, it may have been caused by different versions of my app between the device and simulator)

itsniper commented 11 years ago

The assert is in there because that section of code should never be hit, so there is some other bug elsewhere in the code causing this code to be executed.

I'm using the FSALog macro because I don't like shipping code with asserts. Therefore that next line (localObject = ...) is there, so that in production code if that section of code is ever hit, it will attempt to self-recover.

The break apparently got left in there (but commented out) after some debugging I was doing, but that certainly should not be uncommented. What that will do is only update objects until a missing one is hit. So you will likely end up with objects that are not updated, and an unrecoverable state between the local and remote.

cleqo commented 11 years ago

Yeah i'm using a really modded version of your code and using complete sync only in log in so I thought the duplicated objects were caused by a relationship in one of the many too many objects (and no, there were caused by not uploading manually each object involved in a relationship and only one side), But removing the assert will be enough and works pretty good, all relationships are correct, it doesn't make mistakes in parse but once again I separated the code for uploading objects without a complete sync of the class and I'm deleting also in this way, I had to remove the lastUpdate metadata sync so it doesn't gets holes when a complete sync it's done

itsniper commented 11 years ago

Given that it sounds like you have made a lot of changes to the code, I don't feel this is an issue in the base code. I'm not sure I follow 100% what you are doing, but I think you are making a lot of unnecessary changes. In my apps I am only syncing at login, and by user request, and it works just fine.

Needing to remove lastUpdate is a side-effect of adding that break. Your objects are not syncing the first time like they should.

cleqo commented 11 years ago

No actually, I've just made separate methods for uploading and deleting in your sync methods, and obviously the uploading and deleting doesn't mean a sync so I leave untouched the last sync for the class, and it works just as good with sync (I use upload as it has more sense in my app uploading a buch of objects in different classes than searching all the database all the time) It works really nice but, now that I remember I changed the conflict resolution to always update to the last modified object no matter where it comes from, I also added ownerId in FTASyncParent as the ACL in my app it's very complex, but taking that apart It doesn't mess with the base code and I will think its sure to say it will work just fine, and obviously bugs will rise eventually but for me many too many it's good to go