objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
927 stars 115 forks source link

Removing a entity with ToOne relation keeps related entity #547

Closed fernandomoraesvr closed 10 months ago

fernandomoraesvr commented 10 months ago

Not sure if it is a bug or a feature request, but when removing a entity with a ToOne relation, i got the primary entity removed, but the related entity still exists in objectbox.

TODO Provide the following information as needed

Basic info:

Steps to reproduce

  1. Create a entity with a ToOne relation
  2. Save a instance with target value
  3. Delete entity
  4. Entity in ToOne relation still exists in database

Expected behavior

Primary entity and instance of entity of ToOne relation removed aswell.

fernandomoraesvr commented 10 months ago

Ok, sounds like that is a unsupported feature https://github.com/objectbox/objectbox-java/issues/79

However that could be better documented, in Java/Kotlin/Dart docs:

**Removing Objects**
To remove all objects matching a query, call query.remove() .

This led me to understand that ALL objects including relations would be deleted, i'll check if i find some time to contribute and clarify documentation