mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
MixedDatasource: Fixes infinite loop with empty query panel (#44265)
* MixedDatasource: Fixes infinite loop with empty query panel
This commit is contained in:
parent
30aa24a183
commit
a728e9b4dd
@ -2,6 +2,7 @@ import { LoadingState } from '@grafana/data';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { getQueryOptions } from 'test/helpers/getQueryOptions';
|
||||
import { DatasourceSrvMock, MockObservableDataSourceApi } from 'test/mocks/datasource_srv';
|
||||
import { MIXED_DATASOURCE_NAME } from './MixedDataSource';
|
||||
import { MixedDatasource } from './module';
|
||||
|
||||
const defaultDS = new MockObservableDataSourceApi('DefaultDS', [{ data: ['DDD'] }]);
|
||||
@ -126,4 +127,17 @@ describe('MixedDatasource', () => {
|
||||
expect(results[1].state).toBe(LoadingState.Done);
|
||||
});
|
||||
});
|
||||
|
||||
it('should filter out MixedDataSource queries', async () => {
|
||||
const ds = new MixedDatasource({} as any);
|
||||
|
||||
await expect(
|
||||
ds.query({
|
||||
targets: [{ refId: 'A', datasource: { uid: MIXED_DATASOURCE_NAME, id: 'datasource' } }],
|
||||
} as any)
|
||||
).toEmitValuesWith((results) => {
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].data).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ export class MixedDatasource extends DataSourceApi<DataQuery> {
|
||||
query(request: DataQueryRequest<DataQuery>): Observable<DataQueryResponse> {
|
||||
// Remove any invalid queries
|
||||
const queries = request.targets.filter((t) => {
|
||||
return t.datasource?.type !== MIXED_DATASOURCE_NAME;
|
||||
return t.datasource?.uid !== MIXED_DATASOURCE_NAME;
|
||||
});
|
||||
|
||||
if (!queries.length) {
|
||||
|
Loading…
Reference in New Issue
Block a user