File tree Expand file tree Collapse file tree
adminforth/dataConnectors Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,12 @@ import AdminForthBaseConnector from './baseConnector.js';
55import pkg from 'pg' ;
66import { afLogger , dbLogger } from '../modules/logger.js' ;
77
8- const { Client } = pkg ;
8+ const { Client, types } = pkg ;
9+
10+ // postgres-date (used by pg for OID 1114/1082) parses no-TZ strings with new Date(y,m,d,...)
11+ // which treats them as LOCAL server time. Return raw strings so getFieldValue can parse as UTC.
12+ types . setTypeParser ( 1114 , ( val ) => val ) ; // TIMESTAMP WITHOUT TIME ZONE
13+ types . setTypeParser ( 1082 , ( val ) => val ) ; // DATE
914
1015
1116class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDataSourceConnector {
@@ -200,7 +205,7 @@ class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDa
200205 return null ;
201206 }
202207 if ( field . _underlineType == 'timestamp' || field . _underlineType == 'int' ) {
203- return dayjs ( value ) . toISOString ( ) ;
208+ return dayjs ( value . replace ( ' ' , 'T' ) + 'Z' ) . toISOString ( ) ;
204209 } else if ( field . _underlineType == 'varchar' ) {
205210 return dayjs ( value ) . toISOString ( ) ;
206211 } else {
@@ -212,7 +217,7 @@ class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDa
212217 if ( ! value ) {
213218 return null ;
214219 }
215- return dayjs ( value ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
220+ return value ;
216221 }
217222
218223 if ( field . type == AdminForthDataTypes . BOOLEAN ) {
You can’t perform that action at this time.
0 commit comments