Closed adnandautovic closed 1 year ago
Hi @adnandautovic. I can reproduce your issue. It appears to be an oversight on our side after Core added this functionality. It looks like we need to extend setEmbedded
to accept a handleBackLinks
modifier.
Thank you for the quick response!
Closed as it has been fixed by #7772
How frequently does the bug occur?
Always
Description
This feature was added to Realm Core in 12.6.0 and the version of Core currently used in Realm Java is 12.13.0, so I would excpect that manual clearing of orphaned objects is not necessary when migrating from referenced objects to embedded objects. Instead, the app crashes at startup with the message
Cannot convert 'Child' to embedded: at least one object has no incoming links and would be deleted.
.So, in the current version of the app there is
and
So far, no care has been taken to delete orphaned children from the database when a parent is deleted, which means for most users there are going to be Child objects that are not referenced by a Parent. We want to change that now and turn Child into an EmbeddedObject, as follows:
and
With a new migration added:
And on app startup:
However, the automatic handling of the backlinks does not work (i.e. automatic deletion of Child objects in this case). The app crashes on startup. I know from our iOS app that this feature does work in Realm Swift, leading me to believe there is an issue with Realm Java and not with Realm Core.
Stacktrace & log output
Can you reproduce the bug?
Always
Reproduction Steps
No response
Version
10.13.2-transformer-api
What Atlas App Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Android API 32
Build environment
Android Studio version: Android Studio Electric Eel | 2022.1.1 Patch 1 Build #AI-221.6008.13.2211.9514443 Android Build Tools version: 34-rc1 Gradle version: 7.5