diff --git a/public/app/plugins/datasource/postgres/postgres_query.ts b/public/app/plugins/datasource/postgres/postgres_query.ts index c9af5d9d76b..eec972d93f9 100644 --- a/public/app/plugins/datasource/postgres/postgres_query.ts +++ b/public/app/plugins/datasource/postgres/postgres_query.ts @@ -96,6 +96,10 @@ export default class PostgresQuery { } } + hasUnixEpochTimecolumn() { + return ['int4', 'int8', 'float4', 'float8', 'numeric'].indexOf(this.target.timeColumnType) > -1; + } + buildTimeColumn(alias = true) { let timeGroup = this.hasTimeGroup(); let query; @@ -108,7 +112,7 @@ export default class PostgresQuery { } else { args = timeGroup.params[0]; } - if (['int4', 'int8', 'float4', 'float8', 'numeric'].indexOf(this.target.timeColumnType) > -1) { + if (this.hasUnixEpochTimecolumn()) { macro = '$__unixEpochGroup'; } if (alias) { diff --git a/public/app/plugins/datasource/postgres/query_ctrl.ts b/public/app/plugins/datasource/postgres/query_ctrl.ts index af5cd3d05a5..6eda9f33562 100644 --- a/public/app/plugins/datasource/postgres/query_ctrl.ts +++ b/public/app/plugins/datasource/postgres/query_ctrl.ts @@ -523,8 +523,11 @@ export class PostgresQueryCtrl extends QueryCtrl { getWhereOptions() { var options = []; - options.push(this.uiSegmentSrv.newSegment({ type: 'macro', value: '$__timeFilter' })); - // options.push(this.uiSegmentSrv.newSegment({ type: 'macro', value: '$__unixEpochFilter' })); + if (this.queryModel.hasUnixEpochTimecolumn()) { + options.push(this.uiSegmentSrv.newSegment({ type: 'macro', value: '$__unixEpochFilter' })); + } else { + options.push(this.uiSegmentSrv.newSegment({ type: 'macro', value: '$__timeFilter' })); + } options.push(this.uiSegmentSrv.newSegment({ type: 'expression', value: 'Expression' })); return this.$q.when(options); }