Browse Source

fix: pass argument as object and extract client from basemodelSql

pull/7268/head
Pranav C 1 year ago
parent
commit
e0435b5804
  1. 5
      packages/nocodb-sdk/src/lib/formulaHelpers.ts
  2. 13
      packages/nocodb/src/db/formulav2/formulaQueryBuilderv2.ts

5
packages/nocodb-sdk/src/lib/formulaHelpers.ts

@ -46,6 +46,9 @@ export const jsepCurlyHook = {
jsep.hooks.add('gobble-token', function gobbleCurlyLiteral(env) {
const OCURLY_CODE = 123; // {
const CCURLY_CODE = 125; // }
// jsep.addIdentifierChar('.');
// jsep.addIdentifierChar('*');
// jsep.addIdentifierChar('?');
let start = -1;
const { context } = env;
if (
@ -1408,7 +1411,7 @@ export function validateFormulaAndExtractTreeWithType({
{
const sqlUI =
typeof clientOrSqlUi === 'string'
? SqlUiFactory.create(clientOrSqlUi)
? SqlUiFactory.create({ client: clientOrSqlUi })
: clientOrSqlUi;
if (sqlUI) {
const abstractType = sqlUI.getAbstractType(col);

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

@ -80,9 +80,16 @@ async function _formulaQueryBuilder(
tree = validateFormulaAndExtractTreeWithType({
formula: _tree.replaceAll('{{', '{').replaceAll('}}', '}'),
columns,
clientOrSqlUi: await Source.get(
model?.source_id ?? column?.source_id,
).then((source) => source.type),
clientOrSqlUi: baseModelSqlv2.clientType as
| 'mysql'
| 'pg'
| 'sqlite3'
| 'mssql'
| 'mysql2'
| 'oracledb'
| 'mariadb'
| 'sqlite'
| 'snowflake',
});
// populate and save parsedTree to column if not exist

Loading…
Cancel
Save