From 955e5afa459239d06c3f751edc2675bd88c79c76 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Wed, 29 Aug 2018 09:49:23 +0200 Subject: [PATCH] recheck timecolumn when changing table --- .../app/plugins/datasource/postgres/query_ctrl.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public/app/plugins/datasource/postgres/query_ctrl.ts b/public/app/plugins/datasource/postgres/query_ctrl.ts index 9a5b0dbe8ff..43e9839e8bb 100644 --- a/public/app/plugins/datasource/postgres/query_ctrl.ts +++ b/public/app/plugins/datasource/postgres/query_ctrl.ts @@ -201,6 +201,19 @@ export class PostgresQueryCtrl extends QueryCtrl { tableChanged() { this.target.table = this.tableSegment.value; + this.datasource.metricFindQuery(this.metaBuilder.buildColumnQuery('time')).then(result => { + // check if time column is still valid + if (result.length > 0) { + if (!_.find(result, (r: any) => r.text === this.target.timeColumn)) { + let segment = this.uiSegmentSrv.newSegment(result[0].text); + this.timeColumnSegment.html = segment.html; + this.timeColumnSegment.value = segment.value; + + this.timeColumnChanged(); + } + } + }); + this.panelCtrl.refresh(); }