From acf24bd679db1f4d440c70862e8dedfc6dc2b321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 10 Dec 2018 12:56:49 +0100 Subject: [PATCH] Clear query models when changing data source type, fixes #14394 --- public/app/features/panel/metrics_tab.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/public/app/features/panel/metrics_tab.ts b/public/app/features/panel/metrics_tab.ts index 508e7ac1ab4..e7fb8258bf9 100644 --- a/public/app/features/panel/metrics_tab.ts +++ b/public/app/features/panel/metrics_tab.ts @@ -89,10 +89,17 @@ export class MetricsTabCtrl { target.datasource = config.defaultDatasource; } }); - } else if (this.datasourceInstance && this.datasourceInstance.meta.mixed) { - _.each(this.panel.targets, target => { - delete target.datasource; - }); + } else if (this.datasourceInstance) { + // if switching from mixed + if (this.datasourceInstance.meta.mixed) { + _.each(this.panel.targets, target => { + delete target.datasource; + }); + } else if (this.datasourceInstance.meta.id !== datasource.meta.id) { + // we are changing data source type, clear queries + this.panel.targets = [{ refId: 'A' }]; + this.panelCtrl.nextRefId = this.dashboard.getNextQueryLetter(this.panel); + } } this.datasourceInstance = datasource;