fix: keep translations during PUT json object when 'skipTranslation=true' is set [DHIS2-10660] #7538
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
PUT
JSON object operation in generic CRUD controller does replace (clear) the translations even when using theskipTranslation=true
parameter.Findings
The
skipTranslation
flag was not forwarded toMergeParams
performing the merge between existing and update object.This did however not fix the issue because somewhere during or because of the preheat the translations get lost for the persisted object so that at the point of the merge both the updating and the persisted object do not have translations.
I investigated but this feels like a bigger issue in the preheat, a box I did not want to open but that should be opened in a dedicated ticket.
Instead I used a workaround in the controller for the
PUT
operation.When translations should be skipped the persisted object is loaded and the translations copied over to the parsed object so that they appear as part of the source. With this the merge obviously now should not skip translations so the flag is flipped.
Automatic testing
A new test was added to the
AbstractCrudControllerTest
with the following scenario:skipTranslation=true
)