Browse Source

feat(nocodb): revise type parser for timestamp

pull/5601/head
Wing-Kam Wong 2 years ago
parent
commit
205a2a2190
  1. 11
      packages/nocodb-nest/src/db/CustomKnex.ts

11
packages/nocodb-nest/src/db/CustomKnex.ts

@ -1,16 +1,21 @@
import { Knex, knex } from 'knex'; import { Knex, knex } from 'knex';
import { SnowflakeClient } from 'nc-help'; import { SnowflakeClient } from 'nc-help';
import { types } from 'pg'; import pg, { types } from 'pg';
import dayjs from 'dayjs';
import Filter from '../models/Filter'; import Filter from '../models/Filter';
import type { FilterType } from 'nocodb-sdk'; import type { FilterType } from 'nocodb-sdk';
import type { BaseModelSql } from './BaseModelSql'; import type { BaseModelSql } from './BaseModelSql';
pg.defaults.parseInputDatesAsUTC = true;
// override parsing date column to Date() // override parsing date column to Date()
types.setTypeParser(1082, (val) => val); types.setTypeParser(1082, (val) => val);
// override timestamp // override timestamp
types.setTypeParser(1114, (val) => { for (const oid of [1114, 1184]) {
return new Date(val + '+0000'); types.setTypeParser(oid, (val) => {
return dayjs(val).utc(true).local().format('YYYY-MM-DD HH:mm:ssZ');
}); });
}
const opMappingGen = { const opMappingGen = {
eq: '=', eq: '=',

Loading…
Cancel
Save