Skip to content

Commit

Permalink
feat: useUTC connection option for oracle and postgres (#7295)
Browse files Browse the repository at this point in the history
If useUTC is set to true, then for Oracle set environment variable 'ORA_SDTZ' and for postgres set ''PGTZ'
  • Loading branch information
Alankarsharma committed Feb 2, 2021
1 parent d7cb338 commit e06a442
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/driver/oracle/OracleConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export interface OracleConnectionOptions extends BaseConnectionOptions, OracleCo
*/
readonly schema?: string;

/**
* A boolean determining whether to pass time values in UTC or local time. (default: true).
*/
readonly useUTC?: boolean;

/**
* Replication setup.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/driver/oracle/OracleDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ export class OracleDriver implements Driver {
this.connection = connection;
this.options = connection.options as OracleConnectionOptions;

if (this.options.useUTC === true) {
process.env.ORA_SDTZ = 'UTC';
}
// load oracle package
this.loadDependencies();

Expand Down
5 changes: 5 additions & 0 deletions src/driver/postgres/PostgresConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export interface PostgresConnectionOptions extends BaseConnectionOptions, Postgr
*/
readonly schema?: string;

/**
* A boolean determining whether to pass time values in UTC or local time. (default: true).
*/
readonly useUTC?: boolean;

/**
* Replication setup.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/driver/postgres/PostgresDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ export class PostgresDriver implements Driver {
this.connection = connection;
this.options = connection.options as PostgresConnectionOptions;
this.isReplicated = this.options.replication ? true : false;

if(this.options.useUTC) {
process.env.PGTZ = 'UTC';
}
// load postgres package
this.loadDependencies();

Expand Down

0 comments on commit e06a442

Please sign in to comment.