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;
}
} else if (field.mapping) {
}
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'] is undefined.
- It enters the first
if.
- It assigns
null to data['location'].
- It SKIPS the
else if block, so the mapping from lc never 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.
Neo.data.RecordFactoryhas a logic flaw inassignDefaultValueswheredefaultValueassignment takes precedence overmapping.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
defaultValueandmapping(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.if.nulltodata['location'].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.