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