From 959723050fb37062808c27d52ce5808b2d3fd3d7 Mon Sep 17 00:00:00 2001 From: Travis Patterson Date: Tue, 18 Jan 2022 13:54:51 -0700 Subject: [PATCH] Fix change to mixed bahavior (#44179) - If the datasource is already set to mixed, don't change any queries in the editor --- .../query/state/updateQueries.test.ts | 38 +++++++++++++++++++ .../app/features/query/state/updateQueries.ts | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/public/app/features/query/state/updateQueries.test.ts b/public/app/features/query/state/updateQueries.test.ts index 958b49b2583..13dc5b4ad56 100644 --- a/public/app/features/query/state/updateQueries.test.ts +++ b/public/app/features/query/state/updateQueries.test.ts @@ -99,4 +99,42 @@ describe('updateQueries', () => { expect(updated[0].datasource).toEqual({ type: 'old-type', uid: 'old-uid' }); expect(updated[1].datasource).toEqual({ type: 'other-type', uid: 'other-uid' }); }); + + it('should change nothing mixed updated to mixed', () => { + const updated = updateQueries( + { + uid: 'mixed', + type: 'mixed', + meta: { + mixed: true, + }, + } as any, + [ + { + refId: 'A', + datasource: { + uid: 'old-uid', + type: 'old-type', + }, + }, + { + refId: 'B', + datasource: { + uid: 'other-uid', + type: 'other-type', + }, + }, + ], + { + uid: 'mixed', + type: 'mixed', + meta: { + mixed: true, + }, + } as any + ); + + expect(updated[0].datasource).toEqual({ type: 'old-type', uid: 'old-uid' }); + expect(updated[1].datasource).toEqual({ type: 'other-type', uid: 'other-uid' }); + }); }); diff --git a/public/app/features/query/state/updateQueries.ts b/public/app/features/query/state/updateQueries.ts index da30887219d..d6998173599 100644 --- a/public/app/features/query/state/updateQueries.ts +++ b/public/app/features/query/state/updateQueries.ts @@ -21,7 +21,7 @@ export function updateQueries( // Set data source on all queries except expression queries return queries.map((query) => { - if (!isExpressionReference(query.datasource)) { + if (!isExpressionReference(query.datasource) && !newSettings.meta.mixed) { query.datasource = datasource; } return query;