Skip to content

Commit

Permalink
fix(postgres): time column type should be a string (#774)
Browse files Browse the repository at this point in the history
The time column type from PostgreSQL is only time of day (no date). Trying to create a new Date() with that value causes an Invalid Date error.
  • Loading branch information
alexbudure committed Aug 24, 2020
1 parent ba2d2aa commit 237ddbf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/postgresql/src/PostgreSqlConnection.ts
Expand Up @@ -17,7 +17,7 @@ export class PostgreSqlConnection extends AbstractSqlConnection {
const ret: Knex.PgConnectionConfig = super.getConnectionOptions();

if (this.config.get('forceUtcTimezone')) {
[1082, 1083, 1114].forEach(oid => types.setTypeParser(oid, str => new Date(str + 'Z'))); // date, time, timestamp types
[1082, 1114].forEach(oid => types.setTypeParser(oid, str => new Date(str + 'Z'))); // date, timestamp types
(defaults as any).parseInputDatesAsUTC = true;
}

Expand Down

0 comments on commit 237ddbf

Please sign in to comment.