Browse Source

enhancement(nocodb): allow formula callee name case-insensitive

pull/5682/head
Wing-Kam Wong 1 year ago
parent
commit
d5122cf7af
  1. 9
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts
  2. 2
      packages/nocodb/src/db/mapFunctionName.ts

9
packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

@ -578,11 +578,11 @@ async function _formulaQueryBuilder(
const colAlias = a ? ` as ${a}` : '';
pt.arguments?.forEach?.((arg) => {
if (arg.fnName) return;
arg.fnName = pt.callee.name;
arg.fnName = pt.callee.name.toUpperCase();
arg.argsCount = pt.arguments?.length;
});
if (pt.type === 'CallExpression') {
switch (pt.callee.name) {
switch (pt.callee.name.toUpperCase()) {
case 'ADD':
case 'SUM':
if (pt.arguments.length > 1) {
@ -661,13 +661,14 @@ async function _formulaQueryBuilder(
break;
}
const calleeName = pt.callee.name.toUpperCase();
return {
builder: knex.raw(
`${pt.callee.name}(${(
`${calleeName}(${(
await Promise.all(
pt.arguments.map(async (arg) => {
let query = (await fn(arg)).builder.toQuery();
if (pt.callee.name === 'CONCAT') {
if (calleeName === 'CONCAT') {
if (knex.clientType() !== 'sqlite3') {
query = await convertDateFormatForConcat(
arg,

2
packages/nocodb/src/db/mapFunctionName.ts

@ -20,7 +20,7 @@ export interface MapFnArgs {
}
const mapFunctionName = async (args: MapFnArgs): Promise<any> => {
const name = args.pt.callee.name;
const name = args.pt.callee.name.toUpperCase();
let val;
switch (args.knex.clientType()) {

Loading…
Cancel
Save