mirror of
https://github.com/nocodb/nocodb.git
synced 2026-02-02 02:47:29 +00:00
fix: add default value for rollup
This commit is contained in:
@@ -58,9 +58,23 @@ export default async function ({
|
||||
return;
|
||||
}
|
||||
|
||||
qb[columnOptions.rollup_function as string]?.(
|
||||
knex.ref(`${refTableAlias}.${rollupColumn.column_name}`),
|
||||
);
|
||||
if (
|
||||
['sum', 'sumDistinct', 'avgDistinct', 'avg'].includes(
|
||||
columnOptions.rollup_function,
|
||||
)
|
||||
) {
|
||||
qb.select(
|
||||
knex.raw(`COALESCE((??), 0)`, [
|
||||
knex[columnOptions.rollup_function as string]?.(
|
||||
knex.ref(`${refTableAlias}.${rollupColumn.column_name}`),
|
||||
),
|
||||
]),
|
||||
);
|
||||
} else {
|
||||
qb[columnOptions.rollup_function as string]?.(
|
||||
knex.ref(`${refTableAlias}.${rollupColumn.column_name}`),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
switch (relationColumnOption.type) {
|
||||
|
||||
Reference in New Issue
Block a user