mirror of
https://github.com/directus/directus.git
synced 2026-01-31 00:48:16 -05:00
Make sure aggregated columns are returned
This commit is contained in:
@@ -132,8 +132,11 @@ async function parseCurrentLevel(
|
||||
nestedCollectionNodes.push(child);
|
||||
}
|
||||
|
||||
/** Always fetch primary key in case there's a nested relation that needs it */
|
||||
if (columnsToSelectInternal.includes(primaryKeyField) === false) {
|
||||
/**
|
||||
* Always fetch primary key in case there's a nested relation that needs it
|
||||
*/
|
||||
const childrenContainRelational = children.some((child) => child.type !== 'field');
|
||||
if (childrenContainRelational && columnsToSelectInternal.includes(primaryKeyField) === false) {
|
||||
columnsToSelectInternal.push(primaryKeyField);
|
||||
}
|
||||
|
||||
@@ -385,6 +388,17 @@ function removeTemporaryFields(
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure any new aliased aggregate fields are included
|
||||
if (ast.query?.aggregate) {
|
||||
for (const [_operation, aliasMap] of Object.entries(ast.query.aggregate)) {
|
||||
if (!aliasMap) continue;
|
||||
|
||||
for (const [_column, alias] of Object.entries(aliasMap)) {
|
||||
fields.push(alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const rawItem of rawItems) {
|
||||
if (rawItem === null || rawItem === undefined) return rawItem;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user