Changed aggregation schema of computed fields
This commit is contained in:
@@ -17,13 +17,20 @@ const accessor = {
|
||||
if (value === undefined) return;
|
||||
value = value[name];
|
||||
});
|
||||
let valueType = Array.isArray(value) ? 'array' : typeof value;
|
||||
let valueType = getType(value);
|
||||
// If the accessor returns an objet, get the object's value instead
|
||||
while (valueType === 'object') {
|
||||
value = value.value;
|
||||
valueType = Array.isArray(value) ? 'array' : typeof value;
|
||||
valueType = getType(value);
|
||||
}
|
||||
// Return a parse node based on the type returned
|
||||
// Return a discovered parse node
|
||||
if (valueType === 'parseNode') {
|
||||
return {
|
||||
result: value,
|
||||
context,
|
||||
};
|
||||
}
|
||||
// Return a parse node based on the constant type returned
|
||||
if (valueType === 'string' || valueType === 'number' || valueType === 'boolean') {
|
||||
return {
|
||||
result: constant.create({
|
||||
@@ -83,4 +90,11 @@ const accessor = {
|
||||
}
|
||||
}
|
||||
|
||||
function getType(val) {
|
||||
if (!val) return typeof val;
|
||||
if (Array.isArray(val)) return 'array';
|
||||
if (val.parseType) return 'parseNode';
|
||||
return typeof val;
|
||||
}
|
||||
|
||||
export default accessor;
|
||||
|
||||
Reference in New Issue
Block a user