From 5670f510193c9d4878c0a508c5f07033207bf0a1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 31 Mar 2023 15:44:14 +0530 Subject: [PATCH] fix(nocodb): AVG function handler return value correction Signed-off-by: Pranav C --- .../lib/sql/functionMappings/commonFns.ts | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/commonFns.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/commonFns.ts index 9c3a2f3033..22eb5ce1f0 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/commonFns.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/commonFns.ts @@ -91,24 +91,20 @@ export default { ), }; }, - AVG: (args: MapFnArgs) => { + AVG: async (args: MapFnArgs) => { if (args.pt.arguments.length > 1) { - return { - builder: args.fn( - { - type: 'BinaryExpression', - operator: '/', - left: { ...args.pt, callee: { name: 'SUM' } }, - right: { type: 'Literal', value: args.pt.arguments.length }, - }, - args.a, - args.prevBinaryOp - ), - }; + return args.fn( + { + type: 'BinaryExpression', + operator: '/', + left: { ...args.pt, callee: { name: 'SUM' } }, + right: { type: 'Literal', value: args.pt.arguments.length }, + }, + args.a, + args.prevBinaryOp + ); } else { - return { - builder: args.fn(args.pt.arguments[0], args.a, args.prevBinaryOp), - }; + return args.fn(args.pt.arguments[0], args.a, args.prevBinaryOp); } }, FLOAT: async (args: MapFnArgs) => {