-
-
Notifications
You must be signed in to change notification settings - Fork 202
Fix: RecordFactory defaultValue prevents mapping execution #9060
Copy link
Copy link
Closed
Labels
aibugSomething isn't workingSomething isn't workingcoreCore framework functionalityCore framework functionality
Description
Neo.data.RecordFactory has a logic flaw in assignDefaultValues where defaultValue assignment takes precedence over mapping.
Current Logic:
if (Object.hasOwn(field, 'defaultValue')) {
// ...
if (data[fieldName] === undefined) {
data[fieldName] = defaultValue; // Assigns default
}
} else if (field.mapping) { // ELSE IF prevents mapping!
// Mapping logic...
}Problem:
If a field has both defaultValue and mapping (e.g. {name: 'location', mapping: 'lc', defaultValue: null}), and the raw data contains the mapped key (lc) but not the target key (location):
data['location']isundefined.- It enters the first
if. - It assigns
nulltodata['location']. - It SKIPS the
else ifblock, so the mapping fromlcnever happens.
Solution:
The mapping logic must run before the default value check, or they must be decoupled so that mapping can populate the field first, and then the default value fills in only if it remains undefined.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
aibugSomething isn't workingSomething isn't workingcoreCore framework functionalityCore framework functionality