Browse Source

feat: Support Logical function `AND` and `OR`

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/497/head
Pranav C 3 years ago
parent
commit
9ae951797a
  1. 10
      packages/nc-gui/helpers/formulaList.js
  2. 2
      packages/noco-docs/content/en/setup-and-usages/abstract-types.md
  3. 2
      packages/noco-docs/content/en/setup-and-usages/audit.md
  4. 12
      packages/nocodb/src/lib/dataMapper/lib/sql/functionMappings/commonFns.ts

10
packages/nc-gui/helpers/formulaList.js

@ -9,6 +9,16 @@ const validations = {
args: { min: 1 }
}
},
AND: {
validation: {
args: { min: 1 }
}
},
OR: {
validation: {
args: { min: 1 }
}
},
CONCAT: {
validation: { args: { min: 1 } }
},

2
packages/noco-docs/content/en/setup-and-usages/abstract-types.md

@ -328,7 +328,7 @@ menuTitle: 'Abstract Types'
### Formula
For more about formula visit [here](./formula)
### Count

2
packages/noco-docs/content/en/setup-and-usages/audit.md

@ -1,7 +1,7 @@
---
title: 'Audit'
description: 'Audit log'
position: 13
position: 13.5
category: 'Setup and Usages'
menuTitle: 'Audit'
---

12
packages/nocodb/src/lib/dataMapper/lib/sql/functionMappings/commonFns.ts

@ -3,7 +3,7 @@ import {MapFnArgs} from "../mapFunctionName";
export default {
// todo: handle default case
SWITCH: (args: MapFnArgs) => {
const count = Math.floor((args.pt.arguments.length-1) / 2)
const count = Math.floor((args.pt.arguments.length - 1) / 2)
let query = '';
const switchVal = args.fn(args.pt.arguments[0]).toQuery();
@ -23,6 +23,12 @@ export default {
}
return args.knex.raw(`CASE ${query}\n END${args.colAlias}`)
},
TRUE:(_args) => 1,
FALSE:(_args) => 0
TRUE: (_args) => 1,
FALSE: (_args) => 0,
AND: (args: MapFnArgs) => {
return args.knex.raw(`${args.knex.raw(`${args.pt.arguments.map(ar => args.fn(ar).toQuery()).join(' AND ')}`).wrap('(', ')').toQuery()}${args.colAlias}`)
},
OR: (args: MapFnArgs) => {
return args.knex.raw(`${args.knex.raw(`${args.pt.arguments.map(ar => args.fn(ar).toQuery()).join(' OR ')}`).wrap('(', ')').toQuery()}${args.colAlias}`)
},
}

Loading…
Cancel
Save