Fix orphan code toggling behaviour - #3231
Merged
Merged
Conversation
rw251
force-pushed
the
Jongmassey/fix-orphan-behaviour
branch
from
September 11, 2026 08:18
7bb837b to
542e40f
Compare
rw251
force-pushed
the
Jongmassey/fix-orphan-behaviour
branch
from
September 11, 2026 09:41
542e40f to
7e18385
Compare
rw251
marked this pull request as ready for review
September 11, 2026 09:43
rw251
approved these changes
Sep 11, 2026
Refactor previous multiple orphan deletion tests into single test as one subsumed the other. Expect explicitly excluded orphan codes to not be deleted. If they are not kept, then if a user (accidentally) un-resolves their parent then they will silently disappear from the backend state. If the parent code is then re-included (as might be expected in the case of an accidental click), they would be re-added as included not excluded Add orphan deletion/re-inclusion test for an uploaded codelist, i.e. one with no searches from the outset, to replicate a uploaded-codelist specific bug encountered in production.
Users may accidentally and temporarily un-resolve a code which has explicitly excluded descendants. This commit ensures that these explicitly excluded codes (and their descendants) remain, and are no silently removed or silently re-added as with their state flipped to included if the parent is re-included.
In a codelist without searches, deselecting a root code causes the hierarchy to be destroyed server side, but not client side. This is arguably desired behaviour as it allows the user to quickly add missing codes from a large hierarchy by toggling the root code on and off. However there is a bug which means that reselecting the root code causes the UI to display (correctly) that all children are implicitly included, but the back end only retains the root code. Saving the codelist reveals this and all children are excluded. This is a failing test for that scenario.
After orphan code(s) are deleted from a codelist, this may cause the parts of the hierarchy they exist in to be deleted. That meant that when it came time to re-include these codes, we weren't able to ascertain their descendants for inclusion. This commit creates a fresh hierarchy for the purposes of re-inclusion. It also refactors the bulk codeobj insertion used by the re-inclusion process as to avoid the possibility of unique constraint violations.
Jongmassey
force-pushed
the
Jongmassey/fix-orphan-behaviour
branch
from
September 14, 2026 07:29
7e18385 to
ac2d849
Compare
Jongmassey
enabled auto-merge
September 14, 2026 07:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3232 and thereby ensures that if a parent code unrelated to a search is "toggled on and off" (i.e. set to unresolved then included) its children are correctly included.
Along the way we discovered some unexpected behaviour re: explicitly excluded codes - in the scenario described above any explicitly excluded child codes would transition to included in the backend but no the frontend. This PR contains a commit to ensure that their excluded state is preserved.