active_fedora
active_fedora copied to clipboard
related_objects.delete should return deleted object (not array) or nil
When the following code is used to remove a related object from a collection/object, it has unexpected behaviors.
parent_collection.related_objects.delete child_related_object
- if child_related_object is present and deleted - CURRENT: returns [child_related_object] DESIRED: return child_related_object
- if child_related_object is missing, but other related objects exist - returns [child_related_object]; should return child_related_object CURRENT: returns [child_related_object] DESIRED: return nil
- if related objects is empty CURRENT: raises error - ActiveFedora::ObjectNotFoundError: Can't reload an object that hasn't been saved DESIRED: return nil
Originally posted at https://github.com/projecthydra-labs/activefedora-aggregation/issues/36 with discussions that may be of help in understanding this issue.