Skip to content

Support renaming dataset sets

Refs https://redmine.teklia.com/issues/5511

It's already possible to update the Dataset.sets through API & frontend, but the issue is that the DatasetElement related instances are not updated.

We have 2 choices here:

  1. add a bit more complex logic in the UpdateDataset endpoint to support that case, limiting to 1 single set name change
  2. migrate towards a dedicated model for set name, so we have a single resource to update

As having a full model for the set name seems vastly overkill, I suggest the following:

  • extend UpdateDataset to detect changes on Dataset.sets (you'll need to get a diff between old/new values)
    • if we only have additions (even multiple), behave as currently, simply updating Dataset
    • if we only have deletions (even multiple), behave as currently, simply updating Dataset
    • if one (and only 1) set has changed: update dataset & all the related DatasetElement for that name
    • raise a 400 as it's unsupported (we cannot know which set to update in DatasetElement` as several changed).