-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
What happened?
Hello,
I got a problem when trying inside the same transaction to first remove some objects and then replace them with new ones (but with same duplicate key)
Here a very simplified example of what I'm trying to do :
Unable to find source-code formatter for language: dart. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
void example() async { realm.write(() { var eventsToDelete = realm.query<SomeEvent>(r'groupId = $0', [oldEvent.groupId]) realm.deleteMany(eventsToDelete); for(final newEvent in someList) { // I have a duplicate key on ['iso-date', 'slot'] realm.add(SomeEvent('_id', 'iso-date', 'slot', 'groupId')); } }) await realm.syncSession.waitForUpload(); }
I said 'race issue' in the title because, some new events will not have any problem, and some will.
Just before writing this issue, I tried to delete 6 events, then created 6 new events with same duplicate key.
Of the 6, 4 got an error, and for 2 it was okay.
If you need more context or anything do tell me.
Thanks
Repro steps
See example
Version
Flutter 3.7.7
What Atlas Services are you using?
Both Atlas Device Sync and Atlas App Services
What type of application is this?
Flutter Application
Client OS and version
Realm 1.02
Code snippets
No response
Stacktrace of the exception/crash you're getting
No response
Relevant log output
No response