Commit 513c79d3 by Ryan McKinley Committed by Torkel Ödegaard

PanelQueryState: check for existing running query (#16894)

Fixes #16880
parent ec500ed4
...@@ -34,14 +34,22 @@ describe('PanelQueryState', () => { ...@@ -34,14 +34,22 @@ describe('PanelQueryState', () => {
expect(empty.series.length).toBe(0); expect(empty.series.length).toBe(0);
expect(hasRun).toBeFalsy(); expect(hasRun).toBeFalsy();
empty = await state.execute( const query = getQueryOptions({
ds, targets: [{ hide: true, refId: 'X' }, { hide: true, refId: 'Y' }, { hide: true, refId: 'Z' }],
getQueryOptions({ targets: [{ hide: true, refId: 'X' }, { hide: true, refId: 'Y' }, { hide: true, refId: 'Z' }] }) });
);
empty = await state.execute(ds, query);
// should not run any hidden queries' // should not run any hidden queries'
expect(state.getActiveRunner()).toBeFalsy(); expect(state.getActiveRunner()).toBeFalsy();
expect(empty.series.length).toBe(0); expect(empty.series.length).toBe(0);
expect(hasRun).toBeFalsy(); expect(hasRun).toBeFalsy();
// Check for the same query
expect(state.isSameQuery(ds, query)).toBeTruthy();
// Check for differnet queries
expect(state.isSameQuery(new MockDataSourceApi('test'), query)).toBeFalsy();
expect(state.isSameQuery(ds, getQueryOptions({ targets: [{ refId: 'differnet' }] }))).toBeFalsy();
}); });
}); });
......
...@@ -95,6 +95,7 @@ export class PanelQueryState { ...@@ -95,6 +95,7 @@ export class PanelQueryState {
execute(ds: DataSourceApi, req: DataQueryRequest): Promise<PanelData> { execute(ds: DataSourceApi, req: DataQueryRequest): Promise<PanelData> {
this.request = req; this.request = req;
this.datasource = ds;
// Return early if there are no queries to run // Return early if there are no queries to run
if (!req.targets.length) { if (!req.targets.length) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment