Browse Source

fix: pass argument as object and extract client from basemodelSql

pull/7268/head
Pranav C 12 months 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) { jsep.hooks.add('gobble-token', function gobbleCurlyLiteral(env) {
const OCURLY_CODE = 123; // { const OCURLY_CODE = 123; // {
const CCURLY_CODE = 125; // } const CCURLY_CODE = 125; // }
// jsep.addIdentifierChar('.');
// jsep.addIdentifierChar('*');
// jsep.addIdentifierChar('?');
let start = -1; let start = -1;
const { context } = env; const { context } = env;
if ( if (
@ -1408,7 +1411,7 @@ export function validateFormulaAndExtractTreeWithType({
{ {
const sqlUI = const sqlUI =
typeof clientOrSqlUi === 'string' typeof clientOrSqlUi === 'string'
? SqlUiFactory.create(clientOrSqlUi) ? SqlUiFactory.create({ client: clientOrSqlUi })
: clientOrSqlUi; : clientOrSqlUi;
if (sqlUI) { if (sqlUI) {
const abstractType = sqlUI.getAbstractType(col); const abstractType = sqlUI.getAbstractType(col);

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

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

Loading…
Cancel
Save