Bugfix
Detail
#28331
Incorrect update type creation in tUpdate leads to ignoring of hidden attribute changes
For attributes with self-developed memory implementation that redirect values to hidden target attributes, a CreateUpdate is incorrectly created instead of an EditUpdate. As a result, null values cannot be saved.
Concrete scenario:
- Attribute A has a custom memory implementation
- Inputs in A are not saved directly in A, but transformed into the hidden attribute B
- A always displays the value of B multiplied by 10
- Inputs in A are divided by 10 and persisted in B
- Example: Input "100" in A → Store "10" in B → Display "100" in A
Error behavior:
When attempting to set attribute A to zero, a CreateUpdate is generated. As the memory implementation does not persist CreateUpdates with zero values, the desired zero setting has no effect.
Cause:
The tUpdate method automatically creates a CreateUpdate if there is no existing AttributeUpdate without checking whether the associated object already exists.
if (update == null) { update = newCreateUpdate(part); // Always CreateUpdate - FALSE }
Solution
Before the update is created, it must be checked whether the edited object already exists:
- For existing objects: Use EditUpdate
- For new objects: Use CreateUpdate
if (update == null) { TLObject object = getEditedObject(); if (object == null) { update = newCreateUpdate(part); // New object } else { update = newEditUpdateDefault(part, false); // Existing object } }