Browse Source

feat(api): oracledb - formula weekday function support

feat/oracle-support
Pranav C 2 years ago committed by Pranav C
parent
commit
fb50783b94
  1. 26
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/oracle.ts

26
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/oracle.ts

@ -1,5 +1,7 @@
import commonFns from './commonFns';
import { MapFnArgs } from '../mapFunctionName';
import dayjs from 'dayjs';
import { getWeekdayByText } from '../helpers/formulaFnHelper';
const pg = {
...commonFns,
@ -63,19 +65,17 @@ const pg = {
END${colAlias}`
);
},
// WEEKDAY: ({ fn, knex, pt, colAlias }: MapFnArgs) => {
// // isodow: the day of the week as Monday (1) to Sunday (7)
// // WEEKDAY() returns an index from 0 to 6 for Monday to Sunday
// return knex.raw(
// `(EXTRACT(ISODOW FROM ${
// pt.arguments[0].type === 'Literal'
// ? `date '${dayjs(fn(pt.arguments[0])).format('YYYY-MM-DD')}'`
// : fn(pt.arguments[0])
// }) - 1 - ${getWeekdayByText(
// pt?.arguments[1]?.value
// )} % 7 + 7) ::INTEGER % 7 ${colAlias}`
// );
// },
WEEKDAY: ({ fn, knex, pt, colAlias }: MapFnArgs) => {
return knex.raw(
`MOD(to_char(${
pt.arguments[0].type === 'Literal'
? `date '${dayjs(fn(pt.arguments[0])).format('YYYY-MM-DD')}'`
: fn(pt.arguments[0])
},'D') - 2 - ${getWeekdayByText(
pt?.arguments[1]?.value
)} + 7, 7) ${colAlias}`
);
},
};
export default pg;

Loading…
Cancel
Save