Browse Source

fix(nocodb): AVG function handler return value correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5392/head
Pranav C 2 years ago
parent
commit
5670f51019
  1. 28
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/commonFns.ts

28
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) { if (args.pt.arguments.length > 1) {
return { return args.fn(
builder: args.fn( {
{ type: 'BinaryExpression',
type: 'BinaryExpression', operator: '/',
operator: '/', left: { ...args.pt, callee: { name: 'SUM' } },
left: { ...args.pt, callee: { name: 'SUM' } }, right: { type: 'Literal', value: args.pt.arguments.length },
right: { type: 'Literal', value: args.pt.arguments.length }, },
}, args.a,
args.a, args.prevBinaryOp
args.prevBinaryOp );
),
};
} else { } else {
return { return args.fn(args.pt.arguments[0], args.a, args.prevBinaryOp);
builder: args.fn(args.pt.arguments[0], args.a, args.prevBinaryOp),
};
} }
}, },
FLOAT: async (args: MapFnArgs) => { FLOAT: async (args: MapFnArgs) => {

Loading…
Cancel
Save