File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,6 +155,16 @@ async function createMySQLPool({
155155 password,
156156 database,
157157 multipleStatements,
158+ typeCast ( field , next ) {
159+ switch ( field . type ) {
160+ case 'TIMESTAMP' :
161+ case 'DATE' :
162+ case 'DATETIME' :
163+ return field . string ( ) ;
164+ default :
165+ return next ( ) ;
166+ }
167+ } ,
158168 } ) ,
159169 queryTimeout
160170 ) ;
@@ -210,6 +220,8 @@ interface PostgresConfig extends BaseConfig {
210220 driver : 'postgres' ;
211221}
212222
223+ const identity = < T > ( input : T ) => input ;
224+
213225async function createPostgresPool ( {
214226 host,
215227 port,
@@ -225,6 +237,21 @@ async function createPostgresPool({
225237 database,
226238 user,
227239 query_timeout : queryTimeout ,
240+ types : {
241+ getTypeParser ( id , format ) {
242+ switch ( id ) {
243+ case pg . types . builtins . TIMESTAMP :
244+ case pg . types . builtins . TIMESTAMPTZ :
245+ case pg . types . builtins . TIME :
246+ case pg . types . builtins . TIMETZ :
247+ case pg . types . builtins . DATE :
248+ case pg . types . builtins . INTERVAL :
249+ return identity ;
250+ default :
251+ return pg . types . getTypeParser ( id , format ) ;
252+ }
253+ }
254+ }
228255 } ) ;
229256 return postgresPool ( pool ) ;
230257}
You can’t perform that action at this time.
0 commit comments