Skip to content

Support partial updates and removal of previously set fields #237

@MRita443

Description

@MRita443

At the time of writing, we did not find it possible to nullify a previously set optional field, such as the location of an event. After an event is created with a location value, any requests received with a null or non specified location value, are overridden by the pre-existing value in the objectMapper.updateValue(entity, this) in EntityDto.

Discussed solutions include:

  • Replacing optional fields like String? with Optional<String?>, and writing a custom update() function for EntityDto, where:
    • empty = key missing in JSON
    • present + null = key with null value in JSON
    • present + non-null = key with a value in JSON
  • Assuming a true PUT fashion to requests where the dto replaces the whole of the previous entity. This may be problematic because of fields not included in the endpoints, like associatedRoles. Some custom case-by-case logic may be required in controllers to deal with these fields
  • Introduce custom controller logic to deal with null fields
  • Implement a PATCH wrapper as explained here or follow the approach defined here

Because this will only affect the usage of the internal forms, and is ""avoidable"" by giving the field a value like -, we decided not to attempt any of these solutions at the moment as the disturbance to the backend is potentially large and may the delay the MVP timeline further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions