Comments (8)
and one more statement could be useful: if updatedID2s entity is nil, then the object should be inserted instead of being updated.
from synckit.
If primaryKey attribute changes
Primary keys are not expected to change. If you need to change its value for some object, then that's an indication that the field shouldn't be used as the primary key field. Instead, add another field to your object and assign a unique value to it.
If you use an API your objects probably already get a unique value. Otherwise you might want to use [[NSUUID UUID] UUIDString];
The documentation should probably be more explicit about this, I will update it.
Regarding use of NSManagedObjectID
: we can't rely on it because it will change as a result of a model update, so it's not reliable when it comes to tracking objects. SyncKit originally used NSManagedObjectID
but when this limitation became apparent the primaryKey solution was added. I would actually like to completely drop the old behaviour and force users to provide a primaryKey field for their classes, it would avoid several problems.
from synckit.
the problem is with this, that you can add a primaryKey for the object, but that will be just an identifier, as ObjectID, and doesn't avoid duplications in CloudKit with the Name attribute if the user creates them on different devices... that was what primaryKey as a unique identifier meant to me. but ok, I'll try to handle it locally.
from synckit.
Assigning a NSUUID as your identifier when you create objects would fix that issue --it's what I do in my own app
from synckit.
from synckit.
I made modifications and test with it. my final opinion: The NSUUID just an identifier, and unfortunately, it can happen, that objects creates and upload to CloudKit with the same attribute (in my case it's important with one Name attribute just one object can exist, what I can manage, when the user create them, but I can't if there was a chaos with this nil primaryKey values at objects.. finally, of course, I can that too with a final deduplication check - but for those, who had same Problem - must to check the relationship at that objects too, and delete the good one!).
With proper scanning, synchronize database before creating new objects can be duplication avoided. However, if the user's iCloud account and/or Drive is unavailable or the user is not online and does not have the latest database, such problems may occur... and I don't think so that a good idea to handle it just with an easy deletion, rather than ask the user what should do. But in some situation, the user can't decide it, because the user can't see, which one of the same name objects has which relationships with other objects.. this issue needs some workaround.
from synckit.
I get how it's an inconvenience for your use case, but I think de-duplication might be the only solution in this case.
One suggestion would be to check the importContext
for goals with the same name in changeManager:didImportChanges:completion:
, then use the modified
field to work out which one to keep. That way you ensure that de-duplication happens in the child context, before the main context gets updated.
from synckit.
from synckit.
Related Issues (20)
- As a participant, how can I remove myself from sharing? HOT 3
- How to get shared data in WidgetExtension? HOT 1
- Can some objects of a certain class in the local database be out of sync? HOT 1
- Variable of type "List<String>()" is not being uploaded. HOT 3
- Trigger sync HOT 1
- SyncError on macOS HOT 1
- Many-to-many relationships and Core Data HOT 3
- Newly added column is not getting synced after Realm is migrated HOT 5
- How to sync data in widget? HOT 5
- Termination: Cannot unarchive type from non-NSData object. HOT 9
- CoreData URL/URI type fields not synced HOT 3
- Remote schema not reliably created/updated HOT 5
- App repeatedly crashing seconds after start for one user HOT 2
- No such module 'SyncKit' HOT 1
- Realm's EmbeddedObject? HOT 1
- Threading logic bug HOT 3
- modifyRecordsCompletionBlock deprecated on iOS 15 HOT 1
- Error in MultiRealmResultsController in Xcode 14.3 HOT 1
- Parent record's modified date time updated when a child record was synced the first time HOT 3
- Syncing multiple Realms
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from synckit.