Browse Source

feat: add `&` as string concatenation shortcut

pull/7019/head
Pranav C 1 year ago
parent
commit
3dafbaa006
  1. 2
      packages/nc-gui/components/smartsheet/column/FormulaOptions.vue
  2. 19
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

2
packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

@ -74,7 +74,7 @@ const validators = {
const availableFunctions = formulaList
const availableBinOps = ['+', '-', '*', '/', '>', '<', '==', '<=', '>=', '!=']
const availableBinOps = ['+', '-', '*', '/', '>', '<', '==', '<=', '>=', '!=', '&']
const autocomplete = ref(false)

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

@ -774,6 +774,25 @@ async function _formulaQueryBuilder(
}
return { builder: knex.raw(`??${colAlias}`, [builder || pt.name]) };
} else if (pt.type === 'BinaryExpression') {
if(pt.operator === '&'){
return fn(
{
type: 'CallExpression',
arguments: [
pt.left,
pt.right
],
callee: {
type: 'Identifier',
name: 'CONCAT',
},
},
alias,
prevBinaryOp,
);
}
if (pt.operator === '==') {
pt.operator = '=';
}

Loading…
Cancel
Save