Browse Source

feat: add DATESTR function support(PG)

pull/7268/head
Pranav C 12 months ago
parent
commit
9ea8a50077
  1. 10
      packages/nocodb-sdk/src/lib/formulaHelpers.ts
  2. 1
      packages/nocodb-sdk/src/lib/sqlUi/MssqlUi.ts
  3. 2
      packages/nocodb-sdk/src/lib/sqlUi/MysqlUi.ts
  4. 1
      packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts
  5. 1
      packages/nocodb-sdk/src/lib/sqlUi/SnowflakeUi.ts
  6. 2
      packages/nocodb-sdk/src/lib/sqlUi/SqliteUi.ts
  7. 9
      packages/nocodb/src/db/functionMappings/pg.ts

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

@ -386,6 +386,16 @@ const formulas: Record<string, FormulaMeta> = {
], ],
returnType: FormulaDataTypes.DATE, returnType: FormulaDataTypes.DATE,
}, },
DATESTR: {
validation: {
args: {
rqd: 1,
},
},
description: 'Formats a datetime into a string (YYYY-MM-DD)',
examples: ['DATESTR({column1})'],
returnType: FormulaDataTypes.STRING,
},
DATETIME_DIFF: { DATETIME_DIFF: {
validation: { validation: {
args: { args: {

1
packages/nocodb-sdk/src/lib/sqlUi/MssqlUi.ts

@ -919,6 +919,7 @@ export class MssqlUi {
'COUNT', 'COUNT',
'ROUNDDOWN', 'ROUNDDOWN',
'ROUNDUP', 'ROUNDUP',
'DATESTR',
]; ];
} }
} }

2
packages/nocodb-sdk/src/lib/sqlUi/MysqlUi.ts

@ -1289,6 +1289,6 @@ export class MysqlUi {
} }
static getUnsupportedFnList() { static getUnsupportedFnList() {
return ['COUNTA', 'COUNT']; return ['COUNTA', 'COUNT', 'DATESTR'];
} }
} }

1
packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts

@ -948,6 +948,7 @@ export class OracleUi {
'COUNT', 'COUNT',
'ROUNDDOWN', 'ROUNDDOWN',
'ROUNDUP', 'ROUNDUP',
'DATESTR',
]; ];
} }
} }

1
packages/nocodb-sdk/src/lib/sqlUi/SnowflakeUi.ts

@ -980,6 +980,7 @@ export class SnowflakeUi {
'VALUE', 'VALUE',
'COUNTA', 'COUNTA',
'COUNT', 'COUNT',
'DATESTR',
]; ];
} }
} }

2
packages/nocodb-sdk/src/lib/sqlUi/SqliteUi.ts

@ -882,7 +882,7 @@ export class SqliteUi {
'COUNT', 'COUNT',
'ROUNDDOWN', 'ROUNDDOWN',
'ROUNDUP', 'ROUNDUP',
'DATESTR',
]; ];
} }
} }

9
packages/nocodb/src/db/functionMappings/pg.ts

@ -134,6 +134,15 @@ const pg = {
), ),
}; };
}, },
DATESTR: async ({ fn, knex, pt, colAlias }: MapFnArgs) => {
return {
builder: knex.raw(
`TO_DATE(${
(await fn(pt?.arguments[0])).builder
}, 'YYYY-MM-DD') ${colAlias}`,
),
};
},
AND: async (args: MapFnArgs) => { AND: async (args: MapFnArgs) => {
return { return {
builder: args.knex.raw( builder: args.knex.raw(

Loading…
Cancel
Save