fix: Do not save null values for TEAV [DHIS2-21599]#24302
Merged
Conversation
ameenhere
approved these changes
Jun 30, 2026
muilpp
approved these changes
Jun 30, 2026
…s/bundle/persister/AbstractTrackerPersister.java 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
Prevents the tracker importer from persisting tracked entity attribute values with a
null/emptyvalue, and enforces this at the database level by makingtrackedentityattributevalue.valueNOT NULL. Previously, importing an empty value for an attribute that did not yet exist on the tracked entity inserted a meaningless row with a null/empty value instead of doing nothing.Changes
AbstractTrackerPersister.handleTrackedEntityAttributeValues: adds theisDelete && isNewbranch so that sending an empty value for an attribute with no existing value is a no-op. Before this,valueChangedwastruefor new entries, so the empty value fell through tosaveOrUpdateAttributeValueand inserted a row with a null/emptyvalue.TrackedEntityAttributeValue.hbm.xml: marks thevaluepropertynot-null="true", aligning the Hibernate mapping with the new DB constraint.2.44/V2_44_15__teav_value_not_null.sql: deletes any pre-existing rows wherevalue IS NULL(legacy/orphan data — the encryptionencryptedvaluecolumn was already removed inV2_44_6), then appliesALTER COLUMN value SET NOT NULL. Empty string ('') is intentionally still allowed.TrackedEntityAttributeTest: adds two regression tests — one asserting that importing an empty value for an attribute not in the DB persists no row (isDelete && isNew), and a companion asserting that importing an empty value for an existing attribute deletes its row while leaving the others untouched (isDelete && !isNew).