Add in logic to send root datasource as override if needed (#56904)

This commit is contained in:
Kristina
2022-10-14 08:12:04 -05:00
committed by GitHub
parent 2f85172718
commit 3dbb0f1659
2 changed files with 13 additions and 2 deletions

View File

@@ -268,13 +268,13 @@ export async function generateEmptyQuery(
let defaultQuery: Partial<DataQuery> | undefined;
// datasource override is if we have switched datasources with no carry-over - we want to create a new query with a datasource we define
// it's also used if there's a root datasource and there were no previous queries
if (dataSourceOverride) {
datasourceRef = dataSourceOverride;
} else if (queries.length > 0 && queries[queries.length - 1].datasource) {
// otherwise use last queries' datasource
datasourceRef = queries[queries.length - 1].datasource;
} else {
// if neither exists, use the default datasource
datasourceInstance = await getDataSourceSrv().get();
defaultQuery = datasourceInstance.getDefaultQuery?.(CoreApp.Explore);
datasourceRef = datasourceInstance.getRef();