fix: Do not save null values for TEAV [DHIS2-21599] (2.42)#24334
Open
enricocolasante wants to merge 4 commits into
Open
fix: Do not save null values for TEAV [DHIS2-21599] (2.42)#24334enricocolasante wants to merge 4 commits into
enricocolasante wants to merge 4 commits into
Conversation
* fix: Do not save null values for TEAV [DHIS2-21599] * Update dhis-2/dhis-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/AbstractTrackerPersister.java Co-authored-by: marc <marc@dhis2.org> * Fix formatting --------- Co-authored-by: marc <marc@dhis2.org>
|
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.



Summary
Backport of DHIS2-21599 ("Do not save null values for TEAV", #24302) to the 2.42 branch.
As of this change, the tracker importer no longer persists tracked entity attribute values that
have no value. Unlike the master version, this backport does not ship a database migration to
clean up pre-existing null/empty attribute values; instead it adds a data integrity check that
surfaces those rows to administrators so they can be resolved manually. This keeps the stable 2.42
line free of automatic, irreversible data changes on upgrade.
Changes
Tracker import (
AbstractTrackerPersister.java): no longer writes a tracked entity attributevalue when the imported value is empty. An empty value for an existing attribute is treated as a
delete; an empty value for an attribute not yet in the database is a no-op. The deleted entry is
intentionally kept in the in-memory map so later occurrences of the same TE + attribute within the
same import run still see it as existing (the DELETE is not flushed until the end of the run).
Data integrity check instead of a migration: adds
data-integrity-checks/programs/tracked_entity_attribute_null_value.yamland registers it indata-integrity-checks.yaml. The check flags anytrackedentityattributevaluerow whosevaluecolumn is null or empty, distinguishing two cases:
encryptedvaluebut no plain text value (previously confidentialattributes), and
It is marked
SEVERE/is_slowand its recommendation explains, per case, how to either recoverthe plain text or delete the affected rows — mirroring the 2.44 migration notes, but leaving the
action in the administrator's hands rather than performing it automatically.
Tests:
DataIntegrityTrackedEntityAttributeNullValueControllerTest— new controller integration testcovering the no-data, plain-value-present, empty-only, and encrypted-only cases. Anomalous rows
are inserted via raw SQL because the service layer refuses to persist a null value.
TrackedEntityAttributeTest— adds import-level coverage, notablyshouldNotPersistAttributeValueWhenImportingEmptyValueForAttributeNotInDbandshouldDeleteAttributeValueWhenImportingEmptyValueForExistingAttribute.Housekeeping: bumps
section_orderofsingle_events_null_occurred_date.yamlfrom 3 to 6 tomake room for the new check ordering in the Programs section.