realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Add automatic handling of orphan embedded objects during migrations #7772

Closed edualonso closed 1 year ago

edualonso commented 1 year ago

Closes #7769

Added support for automatic handling of back links during migrations.

adnandautovic commented 1 year ago

Thank you very much for providing a fix so quickly! If I may comment on this change after reading into the calls to Realm Core a bit: While the issue I opened refered specifically to the removal of orphaned objects, the Realm Core functionality of handle_backlinks actually does a bit more than deleting orphans. At the time of writing, it also automatically clones objects that have multiple references. Therefore, I believe the parameter name boolean deleteOrphanChildren and its corresponding comment are slightly misleading. I think the parameter would be more appropriately named boolean handleBackLinks and the Java Doc should point out that all unsatisfied invariants concerning backlinks will be taken care of automatically if it is set to true (leaving only the absence of a primary key as the users' responsibility).

edualonso commented 1 year ago

Thant is a very valid point, thanks for the input.